Module: TimeOptions
Instance Method Summary collapse
Instance Method Details
#current ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/overload/time.rb', line 16 def current if respond_to?(:utc) && time_zone = Lux.current.var[:time_zone] begin tz = TZInfo::Timezone.get(time_zone) tz.utc_to_local utc rescue TZInfo::InvalidTimezoneIdentifier => e Lux.logger(:time_zone).error '%s (%s)' % [e., time_zone] self end else self end end |
#long(use_default = false) ⇒ Object
12 13 14 |
# File 'lib/overload/time.rb', line 12 def long use_default=false current.strftime("#{short(use_default)} %H:%M") end |
#short(use_default = false) ⇒ Object
2 3 4 5 6 7 8 9 10 |
# File 'lib/overload/time.rb', line 2 def short use_default = false # lang = Lux.current.request.env['HTTP_ACCEPT_LANGUAGE'] rescue 'en' default_format = '%Y-%m-%d' date_format = Lux.current.var[:date_format].or(Lux.config[:date_format] || default_format) date_format = default_format if use_default date_format = date_format.sub('yyyy', '%Y').sub('mm', '%m').sub('dd', '%d') current.strftime date_format end |