Module: LogStash::Time

Defined in:
lib/logstash/time.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

DateTime =
org.joda.time.DateTime
DateTimeZone =
org.joda.time.DateTimeZone
ISO8601_STRFTIME =

Otherwise, use ruby stdlib Time, which is much slower than Joda.

"%04d-%02d-%02dT%02d:%02d:%02d.%06d%+03d:00".freeze

Class Method Summary collapse

Class Method Details

.nowObject



15
16
17
18
19
20
21
22
# File 'lib/logstash/time.rb', line 15

def self.now
  # org.joda.time.DateTime#to_s returns the time in ISO8601 form :)
  # Could call DateTime.new(DateTimeZone::UTC) but JRuby calls the
  # DateTime#new(Object) constructor instead of the
  # DateTime#new(DateTimeZone) constructor. I was unable to get java_send to invoke this constructor,
  # so instead I have to do DateTime#new#withZone(UTC)
  return DateTime.new.withZone(DateTimeZone::UTC).to_s
end