Module: LogStash::Time
- Defined in:
- lib/logstash/time_addon.rb
Overview
Provide our own Time wrapper for ISO8601 support Example:
>> LogStash::Time.now.to_iso8601
=> "2010-10-17 00:25:24.619014-0700"
>> LogStash::Time.now.utc.to_iso8601
=> "2010-10-17 07:25:26.788704Z"
Constant Summary collapse
- ISO8601_STRFTIME =
"%04d-%02d-%02dT%02d:%02d:%02d.%06d%+03d:00".freeze
- JODA_ISO8601_PARSER =
JODA_ISO8601_PARSER = org.joda.time.format.ISODateTimeFormat.dateTimeParser JODA_ISO8601_PARSER = org.joda.time.format.ISODateTimeFormat.dateTimeParser
org.joda.time.format.DateTimeFormat.forPattern("yyyy-MM-dd'T'HH:mm:ss.SSSZ")
- UTC =
org.joda.time.DateTimeZone.forID("UTC")
Class Method Summary collapse
Class Method Details
.now ⇒ Object
13 14 15 |
# File 'lib/logstash/time_addon.rb', line 13 def self.now return Time.new.utc end |
.parse_iso8601(t) ⇒ Object
22 23 24 25 |
# File 'lib/logstash/time_addon.rb', line 22 def self.parse_iso8601(t) millis = JODA_ISO8601_PARSER.parseMillis(t) return Time.at(millis / 1000, (millis % 1000) * 1000) end |