Class: Time
- Defined in:
- lib/spiderfw/utils/monkey/time.rb,
lib/spiderfw/utils/monkey/date_time.rb
Overview
Monkey-patched conversions to Date and DateTime
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.lparse(string, format = :default, locale = nil, options = {}) ⇒ Object
56 57 58 59 60 |
# File 'lib/spiderfw/utils/monkey/date_time.rb', line 56 def self.lparse(string, format = :default, locale=nil, ={}) locale ||= Spider.locale [:return] = :time Spider::I18n.parse_dt(locale, string, format, ) end |
Instance Method Details
#lformat(format = :default, locale = nil) ⇒ Object
6 7 8 9 |
# File 'lib/spiderfw/utils/monkey/time.rb', line 6 def lformat(format = :default, locale=nil) locale ||= Spider.locale Spider::I18n.localize(locale, self, format) end |
#to_date ⇒ Object
11 12 13 |
# File 'lib/spiderfw/utils/monkey/time.rb', line 11 def to_date ::Date.new(year, month, day) end |
#to_datetime ⇒ Object
14 15 16 |
# File 'lib/spiderfw/utils/monkey/time.rb', line 14 def to_datetime ::DateTime.civil(year, month, day, hour, min, sec, Rational(utc_offset, 86400)) end |