How can this be achieved in Codea? My 20 year old Pocket Secretary with nearly no memory or processing power churns this out like no tomorrow (pun intended) .
I started a little project to keep track of employee’s work schedule for this year and upcoming years. There are three crews that work 24 hours and off 48 hours with a calculatable time off every month. I do this now in a PC program called Calendar Creator and just print out the year in advance. Instead of print, I thought it might be cool to have the schedule on my iPad and add a few features (payday, holidays, etc.) like in Calendar Creator. This part of the project should be relatively easy. The standard Perpetual Calendar part is what is giving me a hard time. I was hoping to do this project without any help but alas I am stumped.
I’m not looking for code but perhaps a point in the right direction of how to fill in the dates of the calendar automatically as the month/year is advanced via touch buttons. I have completed this year manually and thought why not use the standard formula that has been around for many years to do this for me. I found a few Lua and Java scripts that failed to work after being massaged for Codea. I even tried only snippets of the code but to no avail.
There doesn’t seem to be very much info about os.date in the Codea or Lua manuals that I could see but a web search turned up a bit more.
I found the following quite useful info on the PtokaX Wiki at: http://wiki.ptokax.ch/doku.php/scriptinghelp/osdate
os.date ([format [, time]])
Returns a string or a table containing date and time, formatted according to the given string format.
If the time argument is present, this is the time to be formatted (see the os.time function for a description of this value). Otherwise, date formats the current time.
If format starts with ‘!’, then the date is formatted in Coordinated Universal Time. After this optional character, if format is the string “*t”, then date returns a table with the following fields: year (four digits), month (1–12), day (1–31), hour (0–23), min (0–59), sec (0–61), wday (weekday, Sunday is 1), yday (day of the year), and isdst (daylight saving flag, a boolean). Example for the previous sentence: os.date(“*t”).year = 2006
If format is not “*t”, then date returns the date as a string, formatted according to the same rules as the C function strftime. The acceptable formats are as the following:
”%a” The abbreviated weekday name. Example: Thu. ”%A” The full weekday name. Example: Thursday. ”%b” The abbreviated month name. Example: Sep. ”%B” The full month name. Example: September. ”%d” The two-digit day of the month padded with leading zeroes if applicable. Example: 09. ”%e” The day of the month space padded if applicable. Example: 9. ”%H” The two-digit military time hour padded with a zero if applicable. Example: 16. ”%I” The two-digit hour on a 12-hour clock padded with a zero if applicable. Example: 04. ”%j” The three-digit day of the year padded with leading zeroes if applicable. Example: 040. ”%k” The two-digit military time hour padded with a space if applicable. Example: 9. ”%l” The hour on a 12-hour clock padded with a space if applicable. Example: 4. ”%m” The two-digit month padded with a leading zero if applicable. Example: 09. ”%M” The two-digits minute padded with a leading zero if applicable. Example: 02. ”%p” Either AM or PM. Language dependent. ”%S” The two-digit second padded with a zero if applicable. Example: 04. ”%w” The numeric day of the week ranging from 0 to 6 where 0 is Sunday. Example: 0. ”%x” The language-aware standard date representation. For most languages, this is just the same as %B %d, %Y. Example: September 06, 2002. ”%X” The language-aware time representation. For most languages, this is just the same as %I:%M %p. Example: 04:31 PM. ”%y” The two-digit year padded with a leading zero if applicable. Example: 01. ”%Y” The four-digit year. Example: 2001.
When called without arguments, date returns a reasonable date and time representation that depends on the host system and on the current locale (that is, os.date() is equivalent to os.date(”%c”)).
I only tried 4 or 5 of these and they all worked. Perhaps this could be added to the manual at some point.
Problem is, at least to my newbie eyes, this is current time and I can’t find a way to move forward or backwards in time.
Thanks for any help that may be provided.