Library Token for Dates (Gregorian Calendar)
Posted: Tue Oct 29, 2019 5:38 am
This framework can do basic operations with dates of the Gregorian ("real life") calendar. Leap years are fully accounted for.
B.C. years (years prior to year 1) are not currently supported, but all subsequent years are.
Features:
- Get the moon phase and weekday of a date
- Add days to a date
- Get the difference in days between two dates
Date formats supported:
YYYY-M-D (ISO 8601), ex: 2019-10-29
M/D/YYYY (US date), ex: 10/29/2019
Functions available:
- date.getMoon(asText, date): returns the Moon phase of the date. If asText is 1, returns name of phase, otherwise returns phase on a 0 to 8 scale (4: Full Moon).
- date.getWeekday(date): returns the day of the week for the date
- date.dateDifference(date1, date2): returns the number of days between two dates
- date.isDate(date): returns 1 if the date is valid, and 0 otherwise
- date.addDays(days, date): return the date occuring after X days
- date.addWeeks(weeks, date): return the date occuring after X weeks
- date.addMonths(months, date): return the date occuring after X months
- add.addYears(years, date): return the date occuring after X years
- getDay(asText, date): returns the day. If asText is 1, returns it with the text suffix such as "21st" instead of 21.
- getMonth(asText, date): returns the month. If asText is 1, returns the name of the month such as "February"
- getYear(date): returns the year
You can set a "CurrentDate" for your game world with date.setCurrentDate. Once set, omitting the "date" parameter with the previous functions will return information about the current date.
To add days/weeks/months/years to the current date and update it, you can use the following functions:
- addDaysToCurrent(days)
- addWeeksToCurrent(weeks)
- addMonthsToCurrent(months)
- addYearsToCurrent(years)
Examples:
returns "Full"
returns "Sunday, March 13th of 1921"
returns 1924-3-13, 1921, March
returns 1924-3-13
Also available: calendar
Updates:
Installation:
Add the token to one of your maps, and reload the campaign.
updated version 1.5.2: viewtopic.php?p=277883#p277883
Download:
B.C. years (years prior to year 1) are not currently supported, but all subsequent years are.
Features:
- Get the moon phase and weekday of a date
- Add days to a date
- Get the difference in days between two dates
Date formats supported:
YYYY-M-D (ISO 8601), ex: 2019-10-29
M/D/YYYY (US date), ex: 10/29/2019
Functions available:
- date.getMoon(asText, date): returns the Moon phase of the date. If asText is 1, returns name of phase, otherwise returns phase on a 0 to 8 scale (4: Full Moon).
- date.getWeekday(date): returns the day of the week for the date
- date.dateDifference(date1, date2): returns the number of days between two dates
- date.isDate(date): returns 1 if the date is valid, and 0 otherwise
- date.addDays(days, date): return the date occuring after X days
- date.addWeeks(weeks, date): return the date occuring after X weeks
- date.addMonths(months, date): return the date occuring after X months
- add.addYears(years, date): return the date occuring after X years
- getDay(asText, date): returns the day. If asText is 1, returns it with the text suffix such as "21st" instead of 21.
- getMonth(asText, date): returns the month. If asText is 1, returns the name of the month such as "February"
- getYear(date): returns the year
You can set a "CurrentDate" for your game world with date.setCurrentDate. Once set, omitting the "date" parameter with the previous functions will return information about the current date.
To add days/weeks/months/years to the current date and update it, you can use the following functions:
- addDaysToCurrent(days)
- addWeeksToCurrent(weeks)
- addMonthsToCurrent(months)
- addYearsToCurrent(years)
Examples:
Code: Select all
[r: date.getMoon(1, "2019-12-12")]
Code: Select all
[h: date.setCurrentDate("1921-3-13")]
[r: date.getWeekday()], [r: date.getMonth(1)] [r: date.getDay(1)] of [r: date.getYear()]
Code: Select all
[h: date.setCurrentDate("1921-3-13")]
[r: date.addYears(3)],
[r: date.getYear()],
[r: date.getMonth(1)]
Code: Select all
[h: date.setCurrentDate("1921-3-13")]
[h: date.addYearsToCurrent(3)]
[r: date.getDate()]
Also available: calendar
Updates:
Spoiler
Update
1.5.1 (04/13/2020)
- Add option to delete event from date.modifyEventInput
1.5 (03/18/2020)
- New Event system added! The events will show up in the calendar. Use addEventInput to add an event, deleteEventInput to delete it, and modifyEventInput to edit it.
1.4 (03/03/2020)
- Add function "date.showCalendar2", to display a javascript calendar with improved speed.
1.3.1 (11/11/2019)
- Fix addDays and addDaysToCurrent not working correctly when the number of days is negative.
- Add function "date.showCalendar", showing the calendar of the current month.
- Add function "addTimeToCurrent", to add time to the current date through an Input window.
- Add function "date.setDate", to set a new current date through an Input window.
- Add function "date.setCalendar", to set a new current date through the calendar.
1.2
- Add functions date.addWeeks/Months/Years.
- Add functions date.addDaysToCurrent/WeeksToCurrent/MonthsToCurrent/YearsToCurrent
1.1
- Add function date.isDate(date)
1.01
- Fix inverted moon phases for pre-1900 dates
1.5.1 (04/13/2020)
- Add option to delete event from date.modifyEventInput
1.5 (03/18/2020)
- New Event system added! The events will show up in the calendar. Use addEventInput to add an event, deleteEventInput to delete it, and modifyEventInput to edit it.
1.4 (03/03/2020)
- Add function "date.showCalendar2", to display a javascript calendar with improved speed.
1.3.1 (11/11/2019)
- Fix addDays and addDaysToCurrent not working correctly when the number of days is negative.
- Add function "date.showCalendar", showing the calendar of the current month.
- Add function "addTimeToCurrent", to add time to the current date through an Input window.
- Add function "date.setDate", to set a new current date through an Input window.
- Add function "date.setCalendar", to set a new current date through the calendar.
1.2
- Add functions date.addWeeks/Months/Years.
- Add functions date.addDaysToCurrent/WeeksToCurrent/MonthsToCurrent/YearsToCurrent
1.1
- Add function date.isDate(date)
1.01
- Fix inverted moon phases for pre-1900 dates
Add the token to one of your maps, and reload the campaign.
updated version 1.5.2: viewtopic.php?p=277883#p277883
Download: