Module: UU::AppLog::ApplicationLog::TimeConversions
- Included in:
- ApplicationLogAddRecord, ApplicationLogGetRecordList, ApplicationLogRecordAttributes
- Defined in:
- uu_applog-0.27.16/lib/uu/applog/application_log/time_conversions.rb
Overview
Time conversion helper.
Constant Summary
Instance Method Summary (collapse)
-
- (Time) parse_time(val)
Parses the given value into an instance of
Time
representing time in local time. -
- (String) to_iso8601(val)
Converts the given value to a String in ISO8601 format.
Instance Method Details
- (Time) parse_time(val)
Parses the given value into an instance of Time
representing
time in local time.
25 26 27 28 29 30 31 32 33 34 35 |
# File 'uu_applog-0.27.16/lib/uu/applog/application_log/time_conversions.rb', line 25 def parse_time(val) result = nil if val if val.kind_of?String result = Time.parse(val).getlocal elsif (val.kind_of?Fixnum) || (val.kind_of?Float) result = Time.at(val / 1000.0).getlocal end end result end |
- (String) to_iso8601(val)
Converts the given value to a String in ISO8601 format.
40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'uu_applog-0.27.16/lib/uu/applog/application_log/time_conversions.rb', line 40 def to_iso8601(val) result = nil if val if val.kind_of?String result = Time.parse(val).iso8601(FRACTION_DIGITS) elsif val.kind_of?Time result = val.iso8601(FRACTION_DIGITS) elsif val.kind_of?DateTime result = val.to_time.iso8601(FRACTION_DIGITS) end end result end |