pike.git / lib / modules / Calendar.pmod / FAQ

version» Context lines:

pike.git/lib/modules/Calendar.pmod/FAQ:1: + -------------------------------------------------------------------------      Q: I need to parse some date in a non-strict format, like    the one in the HTTP or mail protocol, or from a user web    form.      A: Calendar.dwim_day, or Calendar.dwim_time, should solve    your problem.       > Calendar.dwim_day("1/2/3");    Result: Day(Thu 2 Jan 2003)
pike.git/lib/modules/Calendar.pmod/FAQ:16:    > Calendar.dwim_time("2001 2 3 23:14:23 UTC+9");    Result: Second(Sat 3 Feb 2001 23:14:23 UTC+9)       If it doesn't, and it should, report the problem to me    and I'll see what I can do. Note that the timezones    are rather unpredictable - if it doesn't get it, you    will get the default (local) timezone.      -------------------------------------------------------------------------    + Q: How do I get from unix time (time(2)) to a unit and back? +  + A: Calendar.Unit("unix",time()) +  unit->unix_time() +  +  > Calendar.Day("unix",987654321); +  Result: Day(Thu 19 Apr 2001) +  > Calendar.Second("unix",987654321); +  Result: Second(Thu 19 Apr 2001 6:25:21 CEST) +  +  > Calendar.Day()->unix_time(); +  Result: 979081200 +  +  Note that you will get the time for the start of the unit. +  Unix time is timezone independant. +  +  The day-of-time units (seconds, hours, etc) uses this +  as internal representation of time. +  + ------------------------------------------------------------------------- +  + Q: I'm a mad astronomer, how do I do the same conversions with +  julian day numbers? +  + A: Julian day numbers are used as the internal representation +  for the day, and for most other bigger-then-time-of-day calculations. +  +  > Calendar.Day("julian",2454545); +  Result: Day(Wed 19 Mar 2008) +  > Calendar.Second("julian",2430122.0); +  Result: Second(Tue 6 May 1941 13:00:00 CET) +  +  Julian day numbers from day units and bigger are integers, +  representing the new julian number on that day. Julian day +  numbers from time of day units are represented in floats. +  +  > Calendar.Day()->julian_day(); +  Result: 2451920 +  > Calendar.Second()->julian_day(); +  Result: 2451919.949595 +  +  Watch out for the float precision, though. If you haven't +  compiled your Pike with --with-double-precision, this gives +  you awkwardly low precision - 6 hours. +  + ------------------------------------------------------------------------- +    Q: How do I convert a "Second(Sat 3 Feb 2001 23:14:23 UTC+9)" object    to my timezone?      A: ->set_timezone(your timezone)       > Calendar.dwim_time("2001 2 3 23:14:23 PST")    ->set_timezone("Europe/Stockholm");    Result: Second(Sun 4 Feb 2001 8:14:23 CET)       > Calendar.dwim_time("2001 2 3 23:14:23 PST")
pike.git/lib/modules/Calendar.pmod/FAQ:141:    > Calendar.Day()+3*Calendar.Year();    Result: Day(Sat 10 Jan 2004)    > Calendar.Day()+3*Calendar.Minute()*134;    Result: Minute(Wed 10 Jan 2001 6:42 CET - Thu 11 Jan 2001 6:42 CET)       The last result here is because the resulting time still will    be as long as the first.      -------------------------------------------------------------------------    + Q: Are there other calendars? +  + A: Yes. +  +  Calendar.Day is really a shortcut to Calendar.ISO.Day; +  this is tuned in the localization.h file. +  +  There is currently: +  +  Gregorian +  This is the base module for Julian style calendars; +  despite the name. Most calendars of today are in sync +  with the Gregorian calendar. +  ISO +  This inherits the Gregorian calendar to tweak it to +  conform to the ISO standards. Most affected are weeks, +  which starts on Monday in the ISO calendar. +  This is also the default calendar. +  Discordian +  The Discordian calendar as described in Principia Discordia +  is in sync with the Gregorian calendar (although some claim +  that it should be the Julian - I go with what I can read +  from my Principia Discordia). The module inherits and +  tweaks the Gregorian module. +  Coptic +  The Coptic calendar is by some sources ("St. Marks' +  Coptic Orthodox Church" web pages) is for now on in sync with +  the Gregorian Calendar, so this module too inherits +  and tweaks the Gregorian module. It needs to be +  adjusted for historical use. +  Julian +  This is the Julian calendar, with the small changes +  to the Gregorian calendar (leap years). +  +  Islamic +  This is the Islamic calendar, using the 'Calendrical +  Calculations' rules for new moon. It is based +  directly on the YMD module. +  Stardate +  This is the (TNG) Stardate calendar, which consists +  of one time unit only, the Tick (1000 Tick is one earth year). +  It is based directly on TimeRanges. +  + ------------------------------------------------------------------------- +  + Q: How do I convert between the calendars? +  + A: You give the unit to be converted to the constructor of +  the unit you want it to be. +  +  > Calendar.Coptic.Day(Calendar.dwim_day("14 feb 1983")); +  Result: Day(Mon 7 Ams 1699) +  > Calendar.Islamic.Minute(Calendar.dwim_day("14 feb 1983")); +  Result: Minute(aha 29 Rebîul-âchir 1403 AH 13:00 CET - +  ith 1 Djumâda'l-ûla 1403 AH 13:00 CET) +  > Calendar.Day(Calendar.Stardate.Tick(4711)); +  Result: Day(Sat 17 Sep 2327 0:00 sharp) +  + ------------------------------------------------------------------------- +  + Q: Isn't there a <my country> calendar? +  + A: <your country> uses the ISO calendar, with just different +  names for the months. Language is a parameter to the +  calendar units, as well as the timezone. +  +  You set the language by using ->set_language(yourlanguage). +  +  > t->set_language("portugese")->format_ext_ymd(); +  Result: "Quarta-feira, 10 Janeiro 2001" +  > t->set_language("roman")->format_ext_ymd(); +  Result: "Mercurii dies, X Ianuarius MMDCCLIII ab urbe condita" +  +  Note that all languages aren't supported. If you miss +  your favourite language (or have some time over to help +  me out), look in the Language.pmod file and send me an +  update. +  Or send me a list of the weekdays and month names +  (please start with Monday and January). +  +  Currently, these languages are supported: +  +  iso (aka english) +  +  austrian +  english +  hungarian +  portugese +  spanish +  swedish +  welsh +  +  latin +  roman +  + ------------------------------------------------------------------------- +  + Q: Isn't there a <whatever> calendar? +  + A: Not if it isn't listed above. I'll appreciate any +  implementation help if you happen to have the time over +  to implement some calendar. +  +  I know I miss these: +  +  Chinese +  Jewish or Hebreic +  Maya +  +  Of these, the two first are based on astronomical events, +  which I haven't had the time to look into yet, but the +  last - Maya - is totally numeric. +  + ------------------------------------------------------------------------- +  + Q: I don't like that weeks starts on Mondays. +  Every school kids knows that weeks starts on Sundays. +  + A: According to the ISO 8601 standard, weeks starts on mondays. +  +  If you don't like it, edit the Calendar.pmod/localization.h +  file to use the Gregorian calendar instead of the ISO. +  +  Or use Calendar.Gregorian.Day, etc. +  + ------------------------------------------------------------------------- +    Q: How do I find out which days are red in a specific region?      A: Events.<region>       - contains the events for the region, as a SuperEvent.    You can ask this object to filter out the holidays,       Events.se->holidays();       which will be a superevent containing only holidays.