Module: Date::Format

Defined in:
lib/date/format.rb

Overview

Holds some constants used by the pure ruby parsing code.

The STYLE constant (a hash) allows the user to modify the parsing of DD/DD/DD and DD.DD.DD dates. For DD/DD/DD dates, you can set the :slash entry to :mdy (month/day/year, :dmy (day/month/year), or :ymd (year/month/day). The same can be done for DD.DD.DD dates using the :dot entry. Example:

Date::Format::STYLE[:slash] = :mdy
Date::Format::STYLE[:dot] = :dmy

Constant Summary collapse

STYLE =

On Ruby 1.8.7, DD/DD/DD is interpreted by default as month, day, year, and DD.DD.DD is interpreted by default as year, month, day.

{:dot=>:ymd, :slash=>:mdy}
MONTHS =

Hash mapping lowercase month names to month numbers (e.g. MONTHS => 1)

{
  'january'  => 1, 'february' => 2, 'march'    => 3, 'april'    => 4,
  'may'      => 5, 'june'     => 6, 'july'     => 7, 'august'   => 8,
  'september'=> 9, 'october'  =>10, 'november' =>11, 'december' =>12
}
DAYS =

Hash mapping lowercase day names to day numbers (e.g. DAYS => 0)

{
  'sunday'   => 0, 'monday'   => 1, 'tuesday'  => 2, 'wednesday'=> 3,
  'thursday' => 4, 'friday'   => 5, 'saturday' => 6
}
ABBR_MONTHS =

Hash mapping abbreviated lowercase month names to month numbers (e.g. ABBR_MONTHS => 1)

{
  'jan'      => 1, 'feb'      => 2, 'mar'      => 3, 'apr'      => 4,
  'may'      => 5, 'jun'      => 6, 'jul'      => 7, 'aug'      => 8,
  'sep'      => 9, 'oct'      =>10, 'nov'      =>11, 'dec'      =>12
}
ABBR_DAYS =

Hash mapping abbreviated lowercase day names to day numbers (e.g. ABBR_DAYS => 0)

{
  'sun'      => 0, 'mon'      => 1, 'tue'      => 2, 'wed'      => 3,
  'thu'      => 4, 'fri'      => 5, 'sat'      => 6
}
ZONES =

Hash mapping lowercase time zone names to offsets in seconds (e.g. ZONES => -28800)

{
  'ut'  =>  0*3600, 'gmt' =>  0*3600, 'est' => -5*3600, 'edt' => -4*3600,
  'cst' => -6*3600, 'cdt' => -5*3600, 'mst' => -7*3600, 'mdt' => -6*3600,
  'pst' => -8*3600, 'pdt' => -7*3600,
  'a'   =>  1*3600, 'b'   =>  2*3600, 'c'   =>  3*3600, 'd'   =>  4*3600,
  'e'   =>  5*3600, 'f'   =>  6*3600, 'g'   =>  7*3600, 'h'   =>  8*3600,
  'i'   =>  9*3600, 'k'   => 10*3600, 'l'   => 11*3600, 'm'   => 12*3600,
  'n'   => -1*3600, 'o'   => -2*3600, 'p'   => -3*3600, 'q'   => -4*3600,
  'r'   => -5*3600, 's'   => -6*3600, 't'   => -7*3600, 'u'   => -8*3600,
  'v'   => -9*3600, 'w'   =>-10*3600, 'x'   =>-11*3600, 'y'   =>-12*3600,
  'z'   =>  0*3600,

  'utc' =>  0*3600, 'wet' =>  0*3600,
  'at'  => -2*3600, 'brst'=> -2*3600, 'ndt' => -(2*3600+1800),
  'art' => -3*3600, 'adt' => -3*3600, 'brt' => -3*3600, 'clst'=> -3*3600,
  'nst' => -(3*3600+1800),
  'ast' => -4*3600, 'clt' => -4*3600,
  'akdt'=> -8*3600, 'ydt' => -8*3600,
  'akst'=> -9*3600, 'hadt'=> -9*3600, 'hdt' => -9*3600, 'yst' => -9*3600,
  'ahst'=>-10*3600, 'cat' =>-10*3600, 'hast'=>-10*3600, 'hst' =>-10*3600,
  'nt'  =>-11*3600,
  'idlw'=>-12*3600,
  'bst' =>  1*3600, 'cet' =>  1*3600, 'fwt' =>  1*3600, 'met' =>  1*3600,
  'mewt'=>  1*3600, 'mez' =>  1*3600, 'swt' =>  1*3600, 'wat' =>  1*3600,
  'west'=>  1*3600,
  'cest'=>  2*3600, 'eet' =>  2*3600, 'fst' =>  2*3600, 'mest'=>  2*3600,
  'mesz'=>  2*3600, 'sast'=>  2*3600, 'sst' =>  2*3600,
  'bt'  =>  3*3600, 'eat' =>  3*3600, 'eest'=>  3*3600, 'msk' =>  3*3600,
  'msd' =>  4*3600, 'zp4' =>  4*3600,
  'zp5' =>  5*3600, 'ist' =>  (5*3600+1800),
  'zp6' =>  6*3600,
  'wast'=>  7*3600,
  'cct' =>  8*3600, 'sgt' =>  8*3600, 'wadt'=>  8*3600,
  'jst' =>  9*3600, 'kst' =>  9*3600,
  'east'=> 10*3600, 'gst' => 10*3600,
  'eadt'=> 11*3600,
  'idle'=> 12*3600, 'nzst'=> 12*3600, 'nzt' => 12*3600,
  'nzdt'=> 13*3600,

  'afghanistan'           =>   16200, 'alaskan'               =>  -32400,
  'arab'                  =>   10800, 'arabian'               =>   14400,
  'arabic'                =>   10800, 'atlantic'              =>  -14400,
  'aus central'           =>   34200, 'aus eastern'           =>   36000,
  'azores'                =>   -3600, 'canada central'        =>  -21600,
  'cape verde'            =>   -3600, 'caucasus'              =>   14400,
  'cen. australia'        =>   34200, 'central america'       =>  -21600,
  'central asia'          =>   21600, 'central europe'        =>    3600,
  'central european'      =>    3600, 'central pacific'       =>   39600,
  'central'               =>  -21600, 'china'                 =>   28800,
  'dateline'              =>  -43200, 'e. africa'             =>   10800,
  'e. australia'          =>   36000, 'e. europe'             =>    7200,
  'e. south america'      =>  -10800, 'eastern'               =>  -18000,
  'egypt'                 =>    7200, 'ekaterinburg'          =>   18000,
  'fiji'                  =>   43200, 'fle'                   =>    7200,
  'greenland'             =>  -10800, 'greenwich'             =>       0,
  'gtb'                   =>    7200, 'hawaiian'              =>  -36000,
  'india'                 =>   19800, 'iran'                  =>   12600,
  'jerusalem'             =>    7200, 'korea'                 =>   32400,
  'mexico'                =>  -21600, 'mid-atlantic'          =>   -7200,
  'mountain'              =>  -25200, 'myanmar'               =>   23400,
  'n. central asia'       =>   21600, 'nepal'                 =>   20700,
  'new zealand'           =>   43200, 'newfoundland'          =>  -12600,
  'north asia east'       =>   28800, 'north asia'            =>   25200,
  'pacific sa'            =>  -14400, 'pacific'               =>  -28800,
  'romance'               =>    3600, 'russian'               =>   10800,
  'sa eastern'            =>  -10800, 'sa pacific'            =>  -18000,
  'sa western'            =>  -14400, 'samoa'                 =>  -39600,
  'se asia'               =>   25200, 'malay peninsula'       =>   28800,
  'south africa'          =>    7200, 'sri lanka'             =>   21600,
  'taipei'                =>   28800, 'tasmania'              =>   36000,
  'tokyo'                 =>   32400, 'tonga'                 =>   46800,
  'us eastern'            =>  -18000, 'us mountain'           =>  -25200,
  'vladivostok'           =>   36000, 'w. australia'          =>   28800,
  'w. central africa'     =>    3600, 'w. europe'             =>    3600,
  'west asia'             =>   18000, 'west pacific'          =>   36000,
  'yakutsk'               =>   32400
}