mirror of
https://github.com/elastic/logstash.git
synced 2025-04-24 06:37:19 -04:00
- Fix a bug in iso8601 formatting found by tests
This commit is contained in:
parent
53861618a9
commit
2a1bd53121
1 changed files with 3 additions and 1 deletions
|
@ -20,7 +20,9 @@ class LogStash::Time < ::Time
|
|||
def self.to_iso8601(obj)
|
||||
if obj.is_a?(DateTime)
|
||||
tz = obj.offset == 0 ? "Z" : obj.strftime("%z")
|
||||
return "%s.%06d%s" % [obj.strftime(ISO8601), obj.sec_fraction.to_f, tz]
|
||||
# DateTime#sec_fraction is fractional seconds "of a day"
|
||||
sec_fraction = (obj.sec_fraction.to_f * 86400 * 1000000)
|
||||
return "%s.%06d%s" % [obj.strftime(ISO8601), sec_fraction, tz]
|
||||
else
|
||||
raise "Can't convert object of type #{obj.class} (#{obj}) to iso8601."
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue