class Time
Constants
- FLAT_FORMAT
strftime() format to flatten a date
Public Class Methods
parse_safely(dt)
click to toggle source
Parses the time but never fails. Return value is always in the UTC time zone.
A flattened datetime ā a 14-digit YYYYmmddHHMMMSS ā is fixed to the UTC time zone by parsing it as YYYYmmddHHMMMSSZ <- āZā at end
# File lib/gorillib/datetime/parse.rb, line 11 def self.parse_safely dt return nil if dt.nil? || (dt.respond_to?(:empty) && dt.empty?) begin case when dt.is_a?(Time) then dt.utc when (dt.to_s =~ /\A\d{14}\z/) then parse(dt.to_s+'Z', true) else parse(dt.to_s, true).utc end rescue StandardError => err Log.debug "Can't parse a #{self} from #{dt.inspect}" Log.debug err return nil end end
Public Instance Methods
to_flat()
click to toggle source
Flatten
# File lib/gorillib/datetime/to_flat.rb, line 8 def to_flat utc.strftime(FLAT_FORMAT) end
to_wire(options={})
click to toggle source
# File lib/gorillib/serialization/to_wire.rb, line 45 def to_wire(options={}) self.iso8601 end