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

version» Context lines:

pike.git/lib/modules/Calendar.pmod/YMD.pmod:1: + //! + //! module Calendar + //! submodule YMD + //!   //! base for all Roman-kind of Calendars,   //! ie, one with years, months, weeks and days   //!      #pike __REAL_VERSION__      // #pragma strict_types      import ".";   inherit Time:Time;
pike.git/lib/modules/Calendar.pmod/YMD.pmod:37:   static string f_week_day_name_from_number;   static string f_year_name_from_number;   static string f_year_number_from_name;         static int(0..1) year_leap_year(int y);      static int compat_week_day(int n);      //------------------------------------------------------------------------ + //! class YMD   //! Base (virtual) time period of the Roman-kind of calendar. - class YMD + //! inherits TimeRange   //------------------------------------------------------------------------ -  +  + class YMD   { -  //! inherits TimeRange +     inherit TimeRange;      // --- generic for all YMD:       int y; // year    int yjd; // julian day of the first day of the year       int n; // number of this in the period       int jd; // julian day of first day
pike.git/lib/modules/Calendar.pmod/YMD.pmod:109:    void make_week() // set w from y and yd    {    int wnd,wjd;    [wy,w,wd,wnd,wjd]=week_from_julian_day(jd);    }       int __hash() { return jd; }      // --- query    -  //! @decl float fraction_no() -  //! @decl int hour_no() -  //! @decl int julian_day() -  //! @decl int leap_year() -  //! @decl int minute_no() -  //! @decl int month_day() -  //! @decl int month_no() -  //! @decl int second_no() -  //! @decl int unix_time() -  //! @decl int utc_offset() -  //! @decl int week_day() -  //! @decl int week_no() -  //! @decl int year_day() -  //! @decl int year_no() -  //! @decl string month_name() -  //! @decl string month_shortname() -  //! @decl string month_day_name() -  //! @decl string week_day_name() -  //! @decl string week_day_shortname() -  //! @decl string week_name() -  //! @decl string year_name() -  //! @decl string tzname() -  //! @decl string tzname_iso() + //! method float fraction_no() + //! method int hour_no() + //! method int julian_day() + //! method int leap_year() + //! method int minute_no() + //! method int month_day() + //! method int month_no() + //! method int second_no() + //! method int unix_time() + //! method int utc_offset() + //! method int week_day() + //! method int week_no() + //! method int year_day() + //! method int year_no() + //! method string month_name() + //! method string month_shortname() + //! method string month_day_name() + //! method string week_day_name() + //! method string week_day_shortname() + //! method string week_name() + //! method string year_name() + //! method string tzname() + //! method string tzname_iso()       int julian_day()    {    return jd;    }       int unix_time()    {   // 1970-01-01 is julian day 2440588    int ux=(jd-2440588)*86400;
pike.git/lib/modules/Calendar.pmod/YMD.pmod:259:    return rules->language[f_week_day_shortname_from_number](wd);    }       int leap_year() { return year_leap_year(y); }       int hour_no() { return 0; }    int minute_no() { return 0; }    int second_no() { return 0; }    float fraction_no() { return 0.0; }    + //! function method datetime()   //! This gives back a mapping with the relevant   //! time information (representing the start of the period); -  //! @mapping -  //! @member int "year" -  //! Year number (2000 AD==2000, 1 BC==0). -  //! @member int(1..) "month" -  //! Month of year. -  //! @member int(1..) "day" -  //! Day of month. -  //! @member int(0..) "yearday" -  //! Day of year. -  //! @member int(1..) "week" -  //! Week of year. -  //! @member int(0..) "week_day" -  //! Day of week. -  //! @member int "timezone" -  //! Offset to utc, including dst. -  //! @member int "unix" -  //! Unix time. -  //! @member int "julian" -  //! Julian day. -  //! @member int(0..0) "hour" -  //! Hour of day, including dst (compatibility), always zero. -  //! @member int(0..0) "minute" -  //! Minute of hour (compatibility), always zero. -  //! @member int(0..0) "second" -  //! Second of minute (compatibility), always zero. -  //! @member float "fraction" -  //! Fraction of second (compatibility), always zero. + //! <pre> + //! ([ "year": int // year number (2000 AD=2000, 1 BC==0) + //! "month": int(1..) // month of year + //! "day": int(1..) // day of month + //! "yearday": int(0..) // day of year + //! "week": int(1..) // week of year + //! "week_day": int(0..) // day of week + //! "timezone": int // offset to utc, including dst + //! + //! "unix": int // unix time + //! "julian": int // julian day + //! // for compatibility: + //! "hour": 0 // hour of day, including dst + //! "minute": 0 // minute of hour + //! "second": 0 // second of minute + //! "fraction": 0.0 // fraction of second   //! ]); -  //! @endmapping + //! </pre>   //! -  //! @note + //! note:   //! Day of week is compatible with old versions,   //! ie, 0 is sunday, 6 is saturday, so it shouldn't be   //! used to calculate the day of the week with the given   //! week number. Year day is also backwards compatible,   //! ie, one (1) less then from the year_day() function. -  +     mapping datetime(void|int skip_stuff)    {    if (m==CALUNKNOWN) make_month();    if (w==CALUNKNOWN) make_week();    if (skip_stuff) // called from timeofday    return ([ "year": y,    "month": m,    "day": md,    "yearday": yd-1,    "week": w,
pike.git/lib/modules/Calendar.pmod/YMD.pmod:331:    "hour": 0,    "minute": 0,    "second": 0,    "fraction": 0.0    ]);    }    }      // --- string format ----    -  //! @decl string format_iso_ymd(); -  //! @decl string format_ymd(); -  //! @decl string format_ymd_short(); -  //! @decl string format_ymd_xshort(); -  //! @decl string format_iso_week(); -  //! @decl string format_iso_week_short(); -  //! @decl string format_week(); -  //! @decl string format_week_short(); -  //! @decl string format_month(); -  //! @decl string format_month_short(); -  //! @decl string format_iso_time(); -  //! @decl string format_time(); -  //! @decl string format_time_short(); -  //! @decl string format_time_xshort(); -  //! @decl string format_mtime(); -  //! @decl string format_xtime(); -  //! @decl string format_tod(); -  //! @decl string format_todz(); -  //! @decl string format_xtod(); -  //! @decl string format_mod(); + //! method string format_iso_ymd(); + //! method string format_ymd(); + //! method string format_ymd_short(); + //! method string format_ymd_xshort(); + //! method string format_iso_week(); + //! method string format_iso_week_short(); + //! method string format_week(); + //! method string format_week_short(); + //! method string format_month(); + //! method string format_month_short(); + //! method string format_iso_time(); + //! method string format_time(); + //! method string format_time_short(); + //! method string format_time_xshort(); + //! method string format_mtime(); + //! method string format_xtime(); + //! method string format_tod(); + //! method string format_todz(); + //! method string format_xtod(); + //! method string format_mod();   //! Format the object into nice strings; -  //! @pre{ + //! <pre>   //! iso_ymd "2000-06-02 (Jun) -W22-5 (Fri)" [2]   //! ext_ymd "Friday, 2 June 2000" [2] -  //! ymd "2000-06-02" -  //! ymd_short "20000602" -  //! ymd_xshort "000602" [1] + //! ymd "2000-06-02" + //! ymd_short "20000602" + //! ymd_xshort "000602" [1]   //! iso_week "2000-W22"   //! iso_week_short "2000W22"   //! week "2000-w22" [2]   //! week_short "2000w22" [2]   //! month "2000-06"   //! month_short "200006" [1]   //! iso_time "2000-06-02 (Jun) -W22-5 (Fri) 00:00:00 UTC+1" [2]   //! ext_time "Friday, 2 June 2000, 00:00:00" [2]   //! ctime "Fri Jun 2 00:00:00 2000\n" [2] [3]   //! http "Fri, 02 Jun 2000 00:00:00 GMT" [4] -  //! time "2000-06-02 00:00:00" + //! time "2000-06-02 00:00:00"   //! time_short "20000602 00:00:00"   //! time_xshort "000602 00:00:00" -  //! mtime "2000-06-02 00:00" -  //! xtime "2000-06-02 00:00:00.000000" -  //! tod "00:00:00" -  //! tod_short "000000" -  //! todz "00:00:00 CET" -  //! todz_iso "00:00:00 UTC+1" -  //! xtod "00:00:00.000000" -  //! mod "00:00" -  //! @} -  //! @tt{[1]@} note conflict (think 1 February 2003). -  //! -  //! @tt{[2]@} language dependent. -  //! -  //! @tt{[3]@} as from the libc function @tt{ctime()@}. -  //! -  //! @tt{[4]@} as specified by the HTTP standard; + //! mtime "2000-06-02 00:00" + //! xtime "2000-06-02 00:00:00.000000" + //! tod "00:00:00" + //! tod_short "000000" + //! todz "00:00:00 CET" + //! todz_iso "00:00:00 UTC+1" + //! xtod "00:00:00.000000" + //! mod "00:00" + //! </pre> + //! <tt>[1]</tt> note conflict (think 1 February 2003) + //! <br><tt>[2]</tt> language dependent + //! <br><tt>[3]</tt> as from the libc function ctime() + //! <br><tt>[4]</tt> as specified by the HTTP standard;    //! not language dependent.       string format_iso_ymd()    {    if (m==CALUNKNOWN) make_month();    if (w==CALUNKNOWN) make_week();    return sprintf("%04d-%02d-%02d (%s) -W%02d-%d (%s)",    y,m,md,    month_shortname(),    w,wd, // fixme - what weekday?
pike.git/lib/modules/Calendar.pmod/YMD.pmod:924:    ({z[i]->set_size(uq,sec)})+    map(z[i..sizeof(z)-2],"add",uq,sec);    i++;    }    uo=z[i]->utc_offset();    }    }    return z;    }    -  //! @decl Second second() -  //! @decl Second second(int n) -  //! @decl Minute minute(int hour,int minute,int second) -  //! @decl array(Second) seconds() -  //! @decl array(Second) seconds(int first,int last) -  //! @decl int number_of_seconds() -  //! @decl Minute minute() -  //! @decl Minute minute(int n) -  //! @decl Minute minute(int hour,int minute) -  //! @decl array(Minute) minutes() -  //! @decl array(Minute) minutes(int first,int last) -  //! @decl int number_of_minutes() -  //! @decl Hour hour() -  //! @decl Hour hour(int n) -  //! @decl array(Hour) hours() -  //! @decl array(Hour) hours(int first,int last) -  //! @decl int number_of_hours() + //! method Second second() + //! method Second second(int n) + //! method Minute minute(int hour,int minute,int second) + //! method array(Second) seconds() + //! method array(Second) seconds(int first,int last) + //! method int number_of_seconds() + //! method Minute minute() + //! method Minute minute(int n) + //! method Minute minute(int hour,int minute) + //! method array(Minute) minutes() + //! method array(Minute) minutes(int first,int last) + //! method int number_of_minutes() + //! method Hour hour() + //! method Hour hour(int n) + //! method array(Hour) hours() + //! method array(Hour) hours(int first,int last) + //! method int number_of_hours()       int number_of_hours() { return (number_of_seconds()+3599)/3600; }    cHour hour(void|int n) { return get_unit("hour",n); }    array(cHour) hours(int ...range)    { return get_timeofday("hours",0,3600,Hour,@range); }       int number_of_minutes() { return (number_of_seconds()+59)/60; }    cMinute minute(void|int n,int ... time)    {    if (sizeof(time))
pike.git/lib/modules/Calendar.pmod/YMD.pmod:1007:       void create_julian_day(int|float jd);    static TimeRange _move(int n,YMD step);    TimeRange place(TimeRange what,void|int force);      // not needed       YMD autopromote() { return this; }   }    -  +    //------------------------------------------------------------------------   //! class Year - function(mixed...:cYear) Year=cYear; -  - class cYear +    //! This is the time period of a year. - //------------------------------------------------------------------------ - { +    //! inherits TimeRange   //! inherits YMD -  + //------------------------------------------------------------------------ +  + function(mixed...:cYear) Year=cYear; + class cYear + {    inherit YMD;       constant is_year=1;      // ---    -  //! @decl void create("unix",int unix_time) -  //! @decl void create("julian",int|float julian_day) -  //! @decl void create(int year) -  //! @decl void create(string year) + //! + //! method void create("unix",int unix_time) + //! method void create("julian",int|float julian_day) + //! method void create(int year) + //! method void create(string year)   //! It's possible to create the standard week   //! by using three different methods; either the normal   //! way - from standard unix time or the julian day,   //! and also, for more practical use, from the year number.   //! -  +     void create(mixed ...args)    {    if (!sizeof(args))    {    create_now();    return;    }    else switch (args[0])    {    case "ymd_y":
pike.git/lib/modules/Calendar.pmod/YMD.pmod:1227:      // ---       int number_of_years()    {    return n;    }       int number_of_weeks();    -  //! @decl Month month() -  //! @decl Month month(int n) -  //! @decl Month month(string name) + //! method Month month() + //! method Month month(int n) + //! method Month month(string name)   //! The Year type overloads the month() method,   //! so it is possible to get a specified month   //! by string:   //! -  //! @code{year->month("April")@} + //! <tt>year-&gt;month("April")</tt>   //!   //! The integer and no argument behavior is inherited   //! from <ref to=YMD.month>YMD</ref>(). -  +     cMonth month(int|string ... mp)    {    if (sizeof(mp) &&    stringp(mp[0]))    {    int num=((int)mp[0]) ||    rules->language[f_month_number_from_name](mp[0]);    if (!num)    error("no such month %O in %O\n",mp[0],this_object());       return ::month(num);    }    else    return ::month(@mp);    }    -  //! @decl Week week() -  //! @decl Week week(int n) -  //! @decl Week week(string name) + //! method Week week() + //! method Week week(int n) + //! method Week week(string name)   //! The Year type overloads the week() method,   //! so it is possible to get a specified week   //! by name:   //! -  //! @code{year->week("17")@} -  //! @code{year->week("w17")@} + //! <tt>year-&gt;week("17")</tt> + //! <tt>year-&gt;week("w17")</tt>   //!   //! The integer and no argument behavior is inherited -  //! from @[YMD.week()]. + //! from <ref to=YMD.week>YMD</ref>().   //!   //! This is useful, since the first week of a year   //! not always (about half the years, in the ISO calendar)   //! is numbered '1'.   //! -  +     cWeek week(int|string ... mp)    {    if (sizeof(mp) &&    stringp(mp[0]))    {    int num;    sscanf(mp[0],"%d",num);    sscanf(mp[0],"w%d",num);       cWeek w=::week(num);
pike.git/lib/modules/Calendar.pmod/YMD.pmod:1548:    return Month("ymd_yjmw",r,y,yjd,jd,m,n,wd,w);    }      // --- needs to be defined       static int months_to_month(int y,int m);   }      // ----------------------------------------------------------------   //! class Week - function(mixed...:cWeek) Week=cWeek; -  - class cWeek +    //! The Calendar week represents a standard time period of   //! a week. In the Gregorian calendar, the standard week   //! starts on a sunday and ends on a saturday; in the ISO   //! calendar, it starts on a monday and ends on a sunday.   //!   //! The week are might not be aligned to the year, and thus   //! the week may cross year borders and the year of   //! the week might not be the same as the year of all the   //! days in the week. The basic rule is that the week year   //! is the year that has the most days in the week, but
pike.git/lib/modules/Calendar.pmod/YMD.pmod:1575:   //! the week number and year is the same as for the ISO calendar,   //! except for the sundays.   //!   //! When adding, moving and subtracting months   //! to a week, it falls back to using days.   //!   //! When adding, moving or subtracting years,   //! if tries to place the moved week in the   //! resulting year.   // ---------------------------------------------------------------- +  + function(mixed...:cWeek) Week=cWeek; + class cWeek   {    inherit YMD;       constant is_week=1;    -  //! @decl void create("unix",int unix_time) -  //! @decl void create("julian",int|float julian_day) -  //! @decl void create(int year,int week) + //! + //! method void create("unix",int unix_time) + //! method void create("julian",int|float julian_day) + //! method void create(int year,int week)   //! It's possible to create the standard week   //! by using three different methods; either the normal   //! way - from standard unix time or the julian day,   //! and also, for more practical use, from year and week   //! number.   //! -  +     void create(mixed ...args)    {    if (!sizeof(args))    {    rules=default_rules;    create_unixtime_default(time());    return;    }    else    switch (args[0])
pike.git/lib/modules/Calendar.pmod/YMD.pmod:1830:    ->number_of_months();    }       int number_of_weeks()    {    return n;    }       int number_of_days();    -  //! @decl Day day() -  //! @decl Day day(int n) -  //! @decl Day day(string name) + //! method Day day() + //! method Day day(int n) + //! method Day day(string name)   //! The Week type overloads the day() method,   //! so it is possible to get a specified weekday   //! by string:   //! -  //! @code{week->day("sunday")@} + //! <tt>week-&gt;day("sunday")</tt>   //!   //! The integer and no argument behavior is inherited -  //! from @[YMD.day()]. + //! from <ref to=YMD.day>YMD</ref>().   //! -  //! @note -  //! The weekday-from-string routine is language dependent. + //! note: + //! the weekday-from-string routine is language dependent. +     cDay day(int|string ... mp)    {    if (sizeof(mp) &&    stringp(mp[0]))    {    int num=((int)mp[0]) ||    rules->language[f_week_day_number_from_name](mp[0]);    if (!num)    error("no such day %O in %O\n",mp[0],this_object());   
pike.git/lib/modules/Calendar.pmod/YMD.pmod:1875:   // --- needs to be defined       static int weeks_to_week(int y,int m);   }      // ----------------------------------------------------------------   // Day   // ----------------------------------------------------------------      function(mixed...:cDay) Day=cDay; -  - //! Day. +    class cDay   {    inherit YMD;       constant is_day=1;    int nw;    -  //! @decl void create("unix", int unix_time) -  //! @decl void create("julian", int|float julian_day) -  //! @decl void create(int year, int month,int day) -  //! @decl void create(int year, int year_day) -  //! @decl void create(int julian_day) + //! + //! method void create("unix",int unix_time) + //! method void create("julian",int|float julian_day) + //! method void create(int year,int month,int day) + //! method void create(int year,int year_day) + //! method void create(int julian_day)   //! It's possible to create the day   //! by using five different methods; either the normal   //! way - from standard unix time or the julian day,   //! and also, for more practical use, from year, month and day,   //! from year and day of year, and from julian day   //! without extra fuzz. -  +     void create(mixed ...args)    {    if (!sizeof(args))    {    rules=default_rules;    create_unixtime_default(time());    return;    }    else    switch (args[0])
pike.git/lib/modules/Calendar.pmod/YMD.pmod:2253:    { \    base=Day(@args[..2]); \    return ::create_backtry(@args[3..]); \    } \    return ::create_backtry(@args); \    }         //------------------------------------------------------------------------   //! class Hour - class cHour + //! inherits Time.Hour + //! inherits YMD   //------------------------------------------------------------------------ -  +  + class cHour   { -  //! inherits Time.Hour +     inherit Time::cHour; -  -  //! inherits YMD +     inherit YMD_Time; -  -  //! @ignore +     OVERLOAD_TIMEOFDAY; -  //! @endignore +    }      class cMinute   {    inherit Time::cMinute;    inherit YMD_Time; -  -  //! @ignore +     OVERLOAD_TIMEOFDAY; -  //! @endignore +    }      class cSecond   {    inherit Time::cSecond;    inherit YMD_Time; -  -  //! @ignore +     OVERLOAD_TIMEOFDAY; -  //! @endignore +    }      class cFraction   {    inherit Time::cFraction;    inherit YMD_Time; -  -  //! @ignore +     OVERLOAD_TIMEOFDAY; -  //! @endignore +    }      class cSuperTimeRange   {    inherit Time::cSuperTimeRange;       array(cYear) years(int ...range) { return get_units("years",@range); }    cYear year(void|int n) { return get_unit("years",n); }    int number_of_years() { return num_units("years"); }   
pike.git/lib/modules/Calendar.pmod/YMD.pmod:2349:    string format_iso_week_short() { return RBASE->format_iso_week_short(); }    string format_week() { return RBASE->format_week(); }    string format_week_short() { return RBASE->format_week_short(); }    string format_month() { return RBASE->format_month(); }    string format_month_short() { return RBASE->format_month_short(); }      #undef RBASE   }      //------------------------------------------------------------------------ - // global convinience functions + //! global convinience functions   //------------------------------------------------------------------------    - //! @decl TimeRange parse(string fmt,string arg) + //! method TimeRange parse(string fmt,string arg)   //! parse a date, create relevant object   //! fmt is in the format "abc%xdef..."   //! where abc and def is matched, and %x is   //! one of those time units: - //! @pre{ + //! <pre>   //! %Y absolute year   //! %y dwim year (70-99 is 1970-1999, 0-69 is 2000-2069)   //! %M month (number, name or short name) (needs %y)   //! %W week (needs %y)   //! %D date (needs %y, %m)   //! %d short date (20000304, 000304)   //! %a day (needs %y)   //! %e weekday (needs %y, %w)   //! %h hour (needs %d, %D or %W)   //! %m minute (needs %h)   //! %s second (needs %m)   //! %f fraction of a second (needs %s)   //! %t short time (205314, 2053)   //! %z zone   //! %p "am" or "pm"   //! %n empty string (to be put at the end of formats) - //! @} + //! </pre>   //! - //! @returns - //! Returns 0 if format doesn't match data, or the appropriate time object. + //! returns 0 if format doesn't match data, or the appropriate time object.   //! - //! @note + //! note:   //! The zone will be a guess if it doesn't state an exact   //! regional timezone (like "Europe/Stockholm") -   //! most zone abbriviations (like "CET") are used by more   //! then one region with it's own daylight saving rules.   //! Also beware that for instance CST can be up to four different zones,   //! central Australia or America being the most common.   //! - //! @pre{ + //! <pre>   //! Abbreviation Interpretation   //! AMT America/Manaus [UTC-4]   //! AST America/Curacao [UTC-4]   //! CDT America/Costa_Rica [UTC-6]   //! CST America/El Salvador [UTC-6]   //! EST America/Panama [UTC-5]   //! GST Asia/Dubai [UTC+4]   //! IST Asia/Jerusalem [UTC+2]   //! WST Australia/Perth [UTC+8] - //! @} + //! </pre>   //!   //! This mapping is modifiable in the ruleset, see - //! @[Ruleset.set_abbr2zone()]. + //! <ref>Ruleset.set_abbr2zone</ref>.    -  +    // dwim time of day; needed to correct timezones   // this API may change without further notice   static TimeRange dwim_tod(TimeRange origin,string whut,int h,int m,int s)   {    TimeRange tr;    if (catch {    tr=origin[whut](h,m,s);    } && h==24 && m==0 && s==0) // special case    return origin->end()->second();   
pike.git/lib/modules/Calendar.pmod/YMD.pmod:2673:    return dwim_tod(low,g,h,mi,s);    else    return low;      #ifndef NOCATCH    })   #endif    return 0;   }    - //! @decl Day dwim_day(string date) - //! @decl Day dwim_day(string date,TimeRange context) + //! function Day dwim_day(string date) + //! function Day dwim_day(string date,TimeRange context)   //! Tries a number of different formats on the given date (in order): - //! @pre{ + //! <pre>   //! <ref>parse</ref> format as in   //! "%y-%M-%D (%M) -W%W-%e (%e)" "2000-03-20 (Mar) -W12-1 (Mon)"   //! "%M%/%D/%y" "3/20/2000"   //! "%D%*[ /]%M%*[ /-,]%y" "20/3/2000" "20 mar 2000" "20/3 -00"   //! "%e%*[ ]%D%*[ /]%M%*[ /-,]%y" "Mon 20 Mar 2000" "Mon 20/3 2000"   //! "%y-%M-%D" "2000-03-20", "00-03-20"   //! "%d" "20000320", "000320"   //! "-%y%*[ /]%D%*[ /]%M" "-00 20/3" "-00 20 mar"   //! "-%y%*[ /]%M%*[ /]%D" "-00 3/20" "-00 march 20"   //! "%y%*[ /]%D%*[ /]%M" "00 20 mar" "2000 20/3"   //! "%y%*[ /]%M%*[ /]%D" "2000 march 20"   //! "%M%.%D.%y" "3.20.2000"   //! "%D%*[ -/]%M" "20/3" "20 mar" "20-03"   //! "%M%*[ -/]%D" "3/20" "march 20"   //! "%e%*[ -/wv]%W%*[ -/]%y" "mon w12 -00" "1 w12 2000"   //! "%e%*[ -/wv]%W" "mon w12"   //! "%e" "monday" "1"   //! "today" "today"   //! "last %e" "last monday"   //! "next %e" "next monday" - //! @} + //! </pre>   //! - //! @note + //! note:   //! Casts exception if it fails to dwim out a day.   //! "dwim" means do-what-i-mean.      /* tests:      Calendar.dwim_day("2000-03-20 (Mar) -W12-1 (Mon)");   Calendar.dwim_day("20/3/2000");   Calendar.dwim_day("20 mar 2000");   Calendar.dwim_day("20/3 -00");   Calendar.dwim_day("Mon 20 Mar 2000" );
pike.git/lib/modules/Calendar.pmod/YMD.pmod:2847:    {   // werror("try: %O\n %O\n",   // dayformat+"%*[ ,]"+todformat,   // todformat+"%*[ ,]"+dayformat);    if (dayformat=="")    {    if ( (t=parse(todformat+"%*[ ]%n",what,cx)) ) return t;    }    else    { -  if ( (t=parse(dayformat+"%*[ ,]"+todformat,what,cx)) ) return t; -  if ( (t=parse(todformat+"%*[ ,]"+dayformat,what,cx)) ) return t; +  if ( (t=parse(dayformat+"%*[ ,:]"+todformat,what,cx)) ) return t; +  if ( (t=parse(todformat+"%*[ ,:]"+dayformat,what,cx)) ) return t;    }    }       error("Failed to dwim time from %O\n",what);   }      //-- auxillary functions------------------------------------------------    -  + //! + //! function datetime(int|void unix_time)   //! Replacement for localtime; gives back a mapping: - //! @pre{ + //! <pre>   //! ([ "year": int // year number (2000 AD=2000, 1 BC==0)   //! "month": int(1..) // month of year   //! "day": int(1..) // day of month   //! "yearday": int(1..) // day of year   //! "week": int(1..) // week of year   //! "week_day": int(1..) // day of week (depending on calendar)   //! "unix": int // unix time   //! "julian": float // julian day   //! "hour": int(0..) // hour of day, including dst   //! "minute": int(0..59) // minute of hour   //! "second": int(0..59) // second of minute   //! "fraction": float // fraction of second   //! "timezone": int // offset to utc, including dst   //! ]); - //! @} - //! This is the same as calling @[Second->datetime()]. + //! </pre> + //! This is the same as calling <ref>Second</ref>()-><ref to=Second.datetime>datetime</ref>(). + //! + //! function datetime_name(int|void unix_time) + //! function datetime_short_name(int|void unix_time) + //! Compat functions; same as <ref>format_iso</ref> + //! and <ref>format_iso_short</ref>. + //! + //! function string format_iso(void|int unix_time) + //! function string format_iso_short(void|int unix_time) + //! function string format_iso_tod(void|int unix_time) + //! function string format_day_iso(void|int unix_time) + //! function string format_day_iso_short(void|int unix_time) + //! Format the object into nice strings; + //! <pre> + //! iso "2000-06-02 (Jun) -W22-5 (Fri) 11:57:18 CEST" + //! iso_short "2000-06-02 11:57:18" + //! iso_tod "11:57:18" + //! </pre> +  + // Sane replacement for localtime().   mapping(string:int) datetime(int|void unix_time)   {    return Second("unix",unix_time||time())->datetime();   }    - //! @decl string datetime_name(int|void unix_time) - //! @decl string datetime_short_name(int|void unix_time) - //! Compat functions; same as <ref>format_iso</ref> - //! and <ref>format_iso_short</ref>. -  +    string datetime_name(int|void unix_time)   {    return Second("unix",unix_time||time())->format_iso();   }      string datetime_short_name(int|void unix_time)   {    return Second("unix",unix_time||time())->format_iso_short();   }    - //! @decl string format_iso(void|int unix_time) - //! @decl string format_iso_short(void|int unix_time) - //! @decl string format_iso_tod(void|int unix_time) - //! @decl string format_day_iso(void|int unix_time) - //! @decl string format_day_iso_short(void|int unix_time) - //! Format the object into nice strings; - //! @pre{ - //! iso "2000-06-02 (Jun) -W22-5 (Fri) 11:57:18 CEST" - //! iso_short "2000-06-02 11:57:18" - //! iso_tod "11:57:18" - //! @} -  +    string format_iso(int|void unix_time)   {    return Second("unix",unix_time||time())->format_iso();   }      string format_iso_short(int|void unix_time)   {    return Second("unix",unix_time||time())->format_iso_short();   }