class SafeYAML::Parse::Date

Constants

DATE_MATCHER

This one's easy enough :)

MICROSECONDS_PER_SECOND
SECONDS_PER_DAY
SEC_FRACTION_MULTIPLIER

So this is weird. In Ruby 1.8.7, the DateTime#sec_fraction method returned fractional seconds in units of DAYS for some reason. In 1.9.2, they changed the units -- much more reasonably -- to seconds.

TIME_MATCHER

This unbelievable little gem is taken basically straight from the YAML spec, but made slightly more readable (to my poor eyes at least) to me: yaml.org/type/timestamp.html

Public Class Methods

value(value) click to toggle source
# File lib/safe_yaml/parse/date.rb, line 20
def self.value(value)
  d = DateTime.parse(value)
  usec = d.sec_fraction * SEC_FRACTION_MULTIPLIER
  Time.utc(d.year, d.month, d.day, d.hour, d.min, d.sec, usec) - (d.offset * SECONDS_PER_DAY)
end