Library Token for Dates (Gregorian Calendar)

These are tools and utilities that make it easier to run games. This includes Lib: macro tokens dropped into MapTool to manage the game, a conversion file for CharacterTool to allow use in MapTool, or just about anything else you can think of -- except graphics with macros and anything specific to a particular campaign framework. Those are already covered by the Tilesets subforum and the Links and External Resources forum.

Moderators: dorpond, trevor, Azhrei, giliath, Gamerdude, jay, Mr.Ice

Post Reply
Merudo
Giant
Posts: 228
Joined: Wed Jun 05, 2019 7:06 am

Library Token for Dates (Gregorian Calendar)

Post by Merudo »

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:

Code: Select all

[r: date.getMoon(1, "2019-12-12")]
returns "Full"

Code: Select all

[h: date.setCurrentDate("1921-3-13")]
[r: date.getWeekday()], [r: date.getMonth(1)] [r: date.getDay(1)] of [r: date.getYear()]
returns "Sunday, March 13th of 1921"

Code: Select all

[h: date.setCurrentDate("1921-3-13")]
[r: date.addYears(3)],
[r: date.getYear()],
[r: date.getMonth(1)]
returns 1924-3-13, 1921, March

Code: Select all

[h: date.setCurrentDate("1921-3-13")]
[h: date.addYearsToCurrent(3)]
[r: date.getDate()]
returns 1924-3-13

Also available: calendar
calendar.png
calendar.png (64.91 KiB) Viewed 6524 times
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
Installation:

Add the token to one of your maps, and reload the campaign.

updated version 1.5.2: viewtopic.php?p=277883#p277883

Download:
Attachments
LibDate_v1.5.1.rptok
(28.56 KiB) Downloaded 85 times
Last edited by Merudo on Mon Apr 13, 2020 11:55 am, edited 19 times in total.

Nin
Cave Troll
Posts: 52
Joined: Tue Oct 25, 2011 8:17 am

Re: Library Token for Dates (Gregorian Calendar)

Post by Nin »

Thanks for sharing.

User avatar
BearFather
Cave Troll
Posts: 45
Joined: Tue Jan 07, 2014 11:46 pm
Location: Inside Your Head! <USA>
Contact:

Re: Library Token for Dates (Gregorian Calendar)

Post by BearFather »

I like this idea, one question does it support going back to say year 600? Or is only the data from a certain year on?

Merudo
Giant
Posts: 228
Joined: Wed Jun 05, 2019 7:06 am

Re: Library Token for Dates (Gregorian Calendar)

Post by Merudo »

BearFather wrote:
Tue Oct 29, 2019 10:08 am
I like this idea, one question does it support going back to say year 600? Or is only the data from a certain year on?
It should work for all A.D. years.

B.C. years are not currently supported.

User avatar
Full Bleed
Demigod
Posts: 4736
Joined: Sun Feb 25, 2007 11:53 am
Location: FL

Re: Library Token for Dates (Gregorian Calendar)

Post by Full Bleed »

Thanks for sharing.

I haven't gotten a good look at this yet... but I was wondering how easy this will be to adapt to existing campaign worlds?

For example, my default Campaign world is Greyhawk: https://calendars.wikia.org/wiki/Greyhawk_Calendar
Maptool is the Millennium Falcon of VTT's -- "She may not look like much, but she's got it where it counts."

Merudo
Giant
Posts: 228
Joined: Wed Jun 05, 2019 7:06 am

Re: Library Token for Dates (Gregorian Calendar)

Post by Merudo »

Full Bleed wrote:
Tue Oct 29, 2019 6:01 pm
Thanks for sharing.

I haven't gotten a good look at this yet... but I was wondering how easy this will be to adapt to existing campaign worlds?

For example, my default Campaign world is Greyhawk: https://calendars.wikia.org/wiki/Greyhawk_Calendar
Most of the code would have to be redone. Also, I do not know if there is a way for the Greyhawk dates to be written in the M/D/Y or Y-M-D format. How do you deal with Growfest / Richfest / Brewfest?

User avatar
Full Bleed
Demigod
Posts: 4736
Joined: Sun Feb 25, 2007 11:53 am
Location: FL

Re: Library Token for Dates (Gregorian Calendar)

Post by Full Bleed »

Merudo wrote:
Thu Oct 31, 2019 5:40 am
Most of the code would have to be redone. Also, I do not know if there is a way for the Greyhawk dates to be written in the M/D/Y or Y-M-D format. How do you deal with Growfest / Richfest / Brewfest?
Yeah, those are essentially 7 day interim months. So the month field would have to be string compatible or a decimal:

.5 Needfest
3.5 Growfest
6.5 Richfest
9.5 Brewfest

I, honestly, don't track the calendar in my games very often (more often using broad generalizations)... but that's more because I don't have a good tool to do it. I just wondered how flexible/compatible your core would be to the various game system calendars out there. That calendars.wikia.org site I linked has lots of examples of cool calendars.

Campaign worlds have a habit of showcasing multiple moons, too. ;)
Maptool is the Millennium Falcon of VTT's -- "She may not look like much, but she's got it where it counts."

User avatar
digiacom
Cave Troll
Posts: 44
Joined: Thu Sep 27, 2018 3:00 am

Re: Library Token for Dates (Gregorian Calendar)

Post by digiacom »

Just want to share that I adapted this library token to work with the Eberron calendar and I *love* it :) About to try to upgrade from 1.3.1 and very excited for events!
a.k.a. Melek on Discord.
Check out my Simple 5e Framework!

User avatar
bubblobill
Giant
Posts: 167
Joined: Sun Jan 24, 2010 3:07 pm

Re: Library Token for Dates (Gregorian Calendar)

Post by bubblobill »

Has anyone adapted this for use by the other 6 billion people on the planet?
Bubblobill on the forum.
@Reverend on the MapTool Discord Server

Responsible for less atrocities than most... I do accept responsibility for these though: SmartDoors, Simple d20 Framework - barebones, Drop-in: All 3.5 SRD Monsters, Drop in: Simple Character Editor, Battletech Framework

User avatar
wolph42
Winter Wolph
Posts: 9999
Joined: Fri Mar 20, 2009 5:40 am
Location: Netherlands
Contact:

Re: Library Token for Dates (Gregorian Calendar)

Post by wolph42 »

Small update by Wolph42 and Melek: added 'gm only' function to the dates. Simple checkbox you can turn on or off, showing the event to gms only.
Lib_date1.5.2.rptok
(29.02 KiB) Downloaded 56 times

Post Reply

Return to “Drop-In Macro Resources”