Nammyung's blog

Perpetual Calendar - Part 3a

The previous part looked at an ictime ufun / @function that can handle arbitrary dates with correct day of the week. Now to put that in a nice-looking calendar.

The model for ths is the cal program on unix/linux - a month calendar.

The first thing we want is for players to be able to type +cal and get the calendar for the current month, with the header that looks like this:

Mo Tu We Th Fr Sa Su

Perpetual Calendar - Part 2

The previous part looked at a way to find the day of the week for arbitrary dates outside secs() range. Now, time to put that to use!

One obvious application is to extend time() and secs(). For example, I can make an ictime() ufun / @function that keeps track of time in a game set in the 19th century.

Ideally, you would set the starting date in secs(), then keep track of how much time has passed, comparing the current secs() with the stored starting value. Since we can't do that, we cheat a little.

Perpetual Calendar - Part 1

Problem: time()/secs() and related functions only work for dates between 1970 and 2300 or so because of limitations in the way time is calculated: secs() stores time as number of seconds passed since 1/1/1970, so it can't handle dates before then.

You can get around this with some calculations, but most hand-coded time conversions give up on providing accurate day of the week (MTWTFSS).