| Extracted from Pike v7.8 release 700 at 2013-06-08.

[Top]
7.6::
Calendar
Calendar.YMD
Calendar.YMD.Hour

# Method Calendar.YMD.Hour()->parse()

Method parse

  `TimeRange parse(string fmt, string arg)`

Description

  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:

      %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)
      %S seconds since the Epoch (only combines with %f)
      %f fraction of a second (needs %s or %S)
      %t short time (205314, 2053)
      %z zone
      %p "am" or "pm"
      %n empty string (to be put at the end of formats)

Returns

  0 if format doesn't match data, or the appropriate time object.

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.

          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]

  This mapping is modifiable in the ruleset, see Ruleset.set_abbr2zone . 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):

      parse  format                  as in
          "%y-%M-%D (%M) -W%W-%e (%e)"  "2000-03-20 (Mar) -W12-1 (Mon)"
          "%y-%M-%D"                    "2000-03-20", "00-03-20"
          "%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%*[ /]%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"
          "%D%.%M.%y"                   "20.3.2000"
          "%D%*[ -/]%M"                 "20/3" "20 mar" "20-03"
          "%M%*[ -/]%D"                 "3/20" "march 20"
          "%M-%D-%y"                    "03-20-2000"
          "%D-%M-%y"                    "20-03-2000"
          "%e%*[- /]%D%*[- /]%M"        "mon 20 march"
          "%e%*[- /]%M%*[- /]%D"        "mon/march/20"
          "%e%*[ -/wv]%W%*[ -/]%y"      "mon w12 -00" "1 w12 2000"
          "%e%*[ -/wv]%W"               "mon w12"
          "%d"                          "20000320", "000320"
          "today"                       "today"
          "last %e"                     "last monday"
          "next %e"                     "next monday"

  Casts exception if it fails to dwim out a day. "dwim" means do-what-i-mean.

  function datetime(int|void unix_time) Replacement for localtime; gives back a mapping:

           ([ "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 ().

  function datetime_name(int|void unix_time) function datetime_short_name(int|void unix_time) Compat functions; same as format_iso and format_iso_short .

  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;

          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"