module Chronic
def self.construct(year, month = 1, day = 1, hour = 0, minute = 0, second = 0, offset = nil)
second - Integer second.
minute - Integer minute.
hour - Integer hour.
day - Integer day.
month - Integer month.
year - Integer year.
and leap years.
Construct a new time object determining possible month overflows
def self.construct(year, month = 1, day = 1, hour = 0, minute = 0, second = 0, offset = nil) if second >= 60 minute += second / 60 second = second % 60 end if minute >= 60 hour += minute / 60 minute = minute % 60 end if hour >= 24 day += hour / 24 hour = hour % 24 end # determine if there is a day overflow. this is complicated by our crappy calendar # system (non-constant number of days per month) day <= 56 || raise("day must be no more than 56 (makes month resolution easier)") if day > 28 # no month ever has fewer than 28 days, so only do this if necessary days_this_month = ::Date.leap?(year) ? Date::MONTH_DAYS_LEAP[month] : Date::MONTH_DAYS[month] if day > days_this_month month += day / days_this_month day = day % days_this_month end end if month > 12 if month % 12 == 0 year += (month - 12) / 12 month = 12 else year += month / 12 month = month % 12 end end offset = Time::normalize_offset(offset) if Chronic.time_class.is_a?(DateTime) Chronic.time_class.new(year, month, day, hour, minute, second, offset) end
def self.parse(text, options = {})
text - The String text to parse.
date or time can be found, `nil` will be returned.
will be returned (depending on the value of `:guess`). If no
If the parser can find a date or time, either a Time or Chronic::Span
Parses a string containing a natural language date or time.
def self.parse(text, options = {}) Parser.new(options).parse(text) end