Skip to content

Commit

Permalink
Merge pull request #190 from vigoren/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
vigoren committed Aug 12, 2021
2 parents 038c31e + f10e431 commit a2681e0
Show file tree
Hide file tree
Showing 12 changed files with 272 additions and 427 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# Change Log

## v1.3.28 - API Changes

- Updated the [DateTimeChange hook](./docs/Hooks.md#datetime-change) to have a new property in its returned value called "date". This property contains the same contents as the [API timestampToDate function](./docs/API.md#simplecalendarapitimestamptodatetimestamp) with the current timestamp passed in. This is to have the exact same data available in the hook as the API function. As a result some existing properties will be removed as stated below:
- **Future Breaking**: The property "year" will be removed when Foundry v10 Stable is released. Please use the year information from the new "date" property.
- **Future Breaking**: The property "month" will be removed when Foundry v10 Stable is released. Please use the month information from the new "date" property.
- **Future Breaking**: The property "day" will be removed when Foundry v10 Stable is released. Please use the day information from the new "date" property.
- **Future Breaking**: The property "time" will be removed when Foundry v10 Stable is released. Please use the time information from the new "date" property.
- **Future Breaking**: The property "season" will be removed when Foundry v10 Stable is released. Please use the season information from the new "date" property.
- Updated the [Clock Start/Stop hook](./docs/Hooks.md#clock-startstop) so that it uses the same function as the [API clockStatus function](./docs/API.md#simplecalendarapiclockstatus). No change to returned values, this is to keep consistency between those functions.
- Updated the [PrimaryGM hook](./docs/Hooks.md#is-primary-gm) so that it uses the same function as the [API isPrimaryGM function](./docs/API.md#simplecalendarapiisprimarygm). No change to returned values, this is to keep consistency between those functions.
- Changed when the DateTimeChange hook is fired to include every tick of the clock.
- Added the "isLeapYear" property to the [Date Object](./docs/API.md#date-object) returned by [timeStampToDate API function](./docs/API.md#simplecalendarapitimestamptodatetimestamp) that indicates if the date falls on a leap year or not.

## v1.3.23 - Note Reminders, API Changes, Bug Fixing and Translations

### Note Reminders
Expand Down
51 changes: 27 additions & 24 deletions docs/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -550,24 +550,25 @@ This type contains the current date information

Property|Type|Default Value|Description
---------|-----|-------------|-----------
year|Number|0|The year represented in the timestamp.
yearName|String|""|**Depreciated** Please use display.yearName instead. This will be removed when Foundry v9 Stable is released.
month|Number|0|The index of the month represented in the timestamp.
monthName|String|""|**Depreciated** Please use display.monthName instead. This will be removed when Foundry v9 Stable is released.
dayOffset|Number|0|The number of days that the months days are offset by.
currentSeason|[Season Object](#season-object)|{}|The information for the season of the date, properties include "name" for the seasons name and "color" for the color associated with the season.
day|Number|0|The index of the day of the month represented in the timestamp.
dayDisplay|String|""|**Depreciated** Please use display.day instead. This will be removed when Foundry v9 Stable is released.
dayOfTheWeek|Number|0|The day of the week the day falls on.
dayOffset|Number|0|The number of days that the months days are offset by.
display|[Date Display Object](#date-display-object)|{}|All of the strings associated with displaying the date are put here
hour|Number|0|The hour represented in the timestamp.
isLeapYear|Boolean|false|If this date falls on a leap year.
minute|Number|0|The minute represented in the timestamp.
month|Number|0|The index of the month represented in the timestamp.
monthName|String|""|**Depreciated** Please use display.monthName instead. This will be removed when Foundry v9 Stable is released.
second|Number|0|The seconds represented in the timestamp.
yearZero|Number|0|What is considered as year zero when doing timestamp calculations.
yearPrefix|String|""|**Depreciated** Please use display.yearPrefix instead. This will be removed when Foundry v9 Stable is released.
yearPostfix|String|""|**Depreciated** Please use display.yearPostfix instead. This will be removed when Foundry v9 Stable is released.
weekdays|String Array|[]|A list of weekday names.
showWeekdayHeadings|Boolean|true|If to show the weekday headings for the month.
currentSeason|Season|{}|The information for the season of the date, properties include "name" for the seasons name and "color" for the color associated with the season.
display|[Date Display Object](#date-display-object)|{}|All of the strings associated with displaying the date are put here
weekdays|String Array|[]|A list of weekday names.
year|Number|0|The year represented in the timestamp.
yearName|String|""|**Depreciated** Please use display.yearName instead. This will be removed when Foundry v9 Stable is released.
yearPostfix|String|""|**Depreciated** Please use display.yearPostfix instead. This will be removed when Foundry v9 Stable is released.
yearPrefix|String|""|**Depreciated** Please use display.yearPrefix instead. This will be removed when Foundry v9 Stable is released.
yearZero|Number|0|What is considered as year zero when doing timestamp calculations.


## Date Display Object
Expand All @@ -576,16 +577,16 @@ This type contains the formatted strings used to display the current date and ti

Property|Type|Default Value|Description
---------|-----|-------------|-----------
year|String|""|The year number
yearName|String|""|The name of the year, if year names have been set up.
yearPrefix|String|""|The prefix value for the year
yearPostfix|String|""|The postfix value for the year
month|String|""|The month number.
monthName|String|""|The name of the month.
weekday|String|""|The name of the weekday this date falls on.
day|String|""|How the day is displayed, generally its number on the calendar.
daySuffix|String|""|The Ordinal Suffix associated with the day number (st, nd, rd or th)
month|String|""|The month number.
monthName|String|""|The name of the month.
time|String|''|The hour, minute and seconds.
weekday|String|""|The name of the weekday this date falls on.
year|String|""|The year number
yearName|String|""|The name of the year, if year names have been set up.
yearPostfix|String|""|The postfix value for the year
yearPrefix|String|""|The prefix value for the year

## Date Time Object

Expand Down Expand Up @@ -655,23 +656,25 @@ This type contains information about a moon.

Property|Type|Optional|Default|Description
--------|-----|-------|------|-----------
name|String|No|""|The name of the moon.
cycleLength|Number|No|0|How many days it takes the moon to complete 1 cycle.
color|String|No|"#FFFFFF"|The color associated with the moon.
currentPhase|[Moon Phase Object](#moon-phase-object)|Yes|{}|The moon phase for the current date. This option is present only in results from the [DateTimeChange hook](Hooks.md#datetime-change)
cycleDayAdjust|Number|No|0|A way to nudge the cycle calculations to align with correct dates.
firstNewMoon|[First New Moon Object](#first-new-moon-object)|No|{}|When the first new moon was. This is used to calculate the current phase for a given day.
phases|Array<[Moon Phase Object](#moon-phase-object)>|No|[]|The different phases of the moon.
cycleLength|Number|No|0|How many days it takes the moon to complete 1 cycle.
firstNewMoon|[First New Moon Object](#first-new-moon-object)|Yes|{}|When the first new moon was. This is used to calculate the current phase for a given day.
name|String|No|""|The name of the moon.
phases|Array<[Moon Phase Object](#moon-phase-object)>|Yes|[]|The different phases of the moon.

## Moon Phase Object

This type contains information about a moon phase.

Property|Type|Optional|Default|Description
--------|-----|-------|------|-----------
name|String|No|""|The name of the phase.
icon|[MoonIcons](#simplecalendarapimoonicons)|No|``|The icon to associate with this moon phase.
length|Number|No|0|How many days of the cycle this phase takes up.
name|String|No|""|The name of the phase.
singleDay|Boolean|No|False|If this phase should only take place on a single day.
icon|[MoonIcons](#simplecalendarapimoonicons)|No|``|The icon to associate with this moon phase.


## Note Category Object

Expand Down
176 changes: 101 additions & 75 deletions docs/Hooks.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,30 +17,33 @@ Hook Name|Value|Description
---------|------|----------
[DateTimeChange](#datetime-change)|`"simple-calendar-date-time-change"`|This hook is emitted any time the current date is updated.
[ClockStartStop](#clock-startstop)|`"simple-calendar-clock-start-stop"`|This hook is emitted any time the clock is started/stopped or paused.
[PrimaryGM](#is-primary-gm)|`"simple-calendar-primary-gm"`|This hook is emitted when the current user is promoted to the primary GM role.

## Date/Time Change

### When it is emitted
This hook is emitted any time the current date is updated. The current date can be updated by several means:

- When the GM clicks on the "[Set Current Date](./docs/UpdatingDateTime.md#date-controls)" button after adjusting the current date.
- When the [Set Date/Time macro](./docs/Macros.md#set-date-and-time) is called.
- When the [Change Date/Time macro](./docs/Macros.md#change-date-time) is called.
- When importing settings from [about-time](./docs/Configuration.md#about-time) or [Calendar/Weather](./docs/Configuration.md#calendarweather).
- When the [game world time](./docs/Configuration.md#game-world-time-integration) has changed and Simple Calendar is configured to update when that changes.
- When the GM clicks on the "[Set Current Date](UpdatingDateTime.md#date-controls)" button after adjusting the current date.
- When the [clock](UsingTheCalendar.md#simple-calendars-clock) is running every interval update.
- When the [Set Date/Time API function](API.md#simplecalendarapisetdatedate) is called.
- When the [Change Date/Time API function](API.md#simplecalendarapichangedateinterval) is called.
- When the [game world time](Configuration.md#game-world-time-integration) has changed and Simple Calendar is configured to update when that changes.

### What is passed

When this hook is emitted it will pass a data object that contains information about the new current day. The object will have these top level properties:

Property Name|Default Value|Description
-------------|-------------|------------
year|`{}` - Empty Object|This property will contain all information about the current year.<br/>For a breakdown of that information [see below](#year-properties).
month|`{}` - Empty Object|This property will contain all information about the current month.<br/>For a breakdown of that information [see below](#month-properties).
day|`{}` - Empty Object|This property will contain all information about the current day.<br/>For a breakdown of that information [see below](#day-properties).
time|`{}` - Empty Object|This property will contain all information about the current time.<br/>For a breakdown of that information [see below](#time-properties).
season|`{}` - Empty Object|This property will contain all information about the current season.<br/>For a breakdown of that information [see below](#season-properties).
moons|`[]` - Empty Array|This property will contain all information about the current moons.<br/>For a breakdown of that information [see below](#moon-properties).
Property Name|Type|Default Value|Description
-------------|----|---------|------------
date|[Date Object](API.md#date-object)|`{}`|This contains information about the current date of the calendar.
moons|Array<[Moon Object](API.md#moon-object)>|`[]`|This contains information about the moon(s) phases for the current date.
year|[Year Object](#year-properties)|`{}`|**Depreciated** Please use the date property. This will be removed when Foundry v10 stable is released.
month|[Month Object](#month-properties)|`{}`|**Depreciated** Please use the date property. This will be removed when Foundry v10 stable is released.
day|[Day Object](#day-properties)|`{}`|**Depreciated** Please use the date property. This will be removed when Foundry v10 stable is released.
time|[Time Object](#time-properties)|`{}`|**Depreciated** Please use the date property. This will be removed when Foundry v10 stable is released.
season|[Season Object](#season-properties)|`{}`|**Depreciated** Please use the date property. This will be removed when Foundry v10 stable is released.



#### Year Properties
Expand Down Expand Up @@ -83,28 +86,6 @@ Property Name|Value Type|Description
name|string|The name of the season.
color|string|The hex color representation of the season.

#### Moon Properties

The moon properties is an array of moon objects, one for every moon in the calendar. The moon object is detailed below:

Property Name|Value Type|Description
-------------|-------------|------------
name|string|The name of the moon.
color|string|The hex color representation of the moon.
cycleLength|number|The number of calendar days for 1 cycle of the moon.
cycleDayAdjust|number|A entered adjustment used when calculating the current day of a cycle.
currentPhase|object|An object containing details about the phase the moon is in on this day.

#### Moon Phase Properties

Property Name|Value Type|Description
-------------|-------------|------------
name|string|The name of this moon phase.
icon|string|The css class associated with this moons phase to give the proper icon.
length|number|How many days of the cycle this phase lasts.
singleDay|boolean|If this phase should only happen on one day.


### Examples

#### Hooking to
Expand All @@ -123,52 +104,97 @@ This is an example of the data that is passed with this hook:

```json
{
"year": {
"number": 2021,
"prefix": "",
"postfix": "",
"isLeapYear": false
},
"month": {
"name": "April",
"number": 4,
"intercalary": false,
"numberOfDays": 30,
"numberOfLeapYearDays": 30
},
"day": {
"number": 13
},
"time": {
"hour": "00",
"minute": "00",
"second": "56"
},
"season": {
"name": "Spring",
"color": "#fffce8"
"date": {
"year": 2021,
"month": 6,
"dayOffset": 0,
"day": 8,
"dayOfTheWeek": 5,
"hour": 0,
"minute": 15,
"second": 30,
"yearZero": 1970,
"weekdays": [
"Sunday",
"Monday",
"Tuesday",
"Wednesday",
"Thursday",
"Friday",
"Saturday"
],
"showWeekdayHeadings": true,
"currentSeason": {
"color": "#f3fff3",
"startingMonth": 5,
"startingDay": 19,
"name": "Summer"
},
"moons": [
{
"name": "Moon",
"color": "#ffffff",
"cycleLength": 29.53059,
"cycleDayAdjust": 0.5,
"currentPhase": {
"name": "Waxing Crescent",
"length": 6.3826,
"icon": "waxing-crescent",
"singleDay": false
}
}
]
"isLeapYear": false,
"monthName": "July",
"dayDisplay": "9",
"yearName": "",
"yearPrefix": "",
"yearPostfix": "",
"display": {
"day": "9",
"daySuffix": "th",
"weekday": "Friday",
"monthName": "July",
"month": "7",
"year": "2021",
"yearName": "",
"yearPrefix": "",
"yearPostfix": "",
"time": "00:15:30"
}
},
"moons": [
{
"name": "Moon",
"color": "#ffffff",
"cycleLength": 29.53059,
"cycleDayAdjust": 0.5,
"currentPhase": {
"name": "New Moon",
"length": 1,
"icon": "new",
"singleDay": true
}
}
],
"season": {
"name": "Summer",
"color": "#f3fff3"
},
"month": {
"name": "July",
"number": 7,
"intercalary": false,
"numberOfDays": 31,
"numberOfLeapYearDays": 31
},
"day": {
"number": 9
},
"time": {
"hour": "00",
"minute": "15",
"second": "30"
},
"year": {
"number": 2021,
"prefix": "",
"postfix": "",
"isLeapYear": false
}
}
```
## Clock Start/Stop

### When it is emitted

This event is emitted in the followin cases:
This event is emitted in the following cases:

- When the clock is started.
- When the clock is stopped.
Expand Down Expand Up @@ -215,7 +241,7 @@ This is an example of the data that is passed with this hook:

### When it is emitted

This eventn is emitted when the current users is promoted to the primary GM role.
This event is emitted when the current users is promoted to the primary GM role.

This will happen 5 seconds after loading the game if no other GM is currently in the primary role.

Expand Down
Loading

0 comments on commit a2681e0

Please sign in to comment.