mirror of
https://github.com/elastic/logstash.git
synced 2025-04-24 22:57:16 -04:00
stronger regex and code-style change
This commit is contained in:
parent
95abfdebe8
commit
2e21df8e9e
1 changed files with 4 additions and 10 deletions
|
@ -134,19 +134,13 @@ class LogStash::Filters::Date < LogStash::Filters::Base
|
|||
parser = lambda { |date| joda_parser.parseMillis(date) }
|
||||
when "UNIX" # unix epoch
|
||||
parser = lambda do |date|
|
||||
if /\d+/ === date || date.is_a?(Numeric)
|
||||
raise "Invalid UNIX epoch value '#{date}'" unless /^\d+(\.\d+)?$/ === date || date.is_a?(Numeric)
|
||||
(date.to_f * 1000).to_i
|
||||
else
|
||||
raise "Invalid UNIX epoch value '#{date}'"
|
||||
end
|
||||
end
|
||||
when "UNIX_MS" # unix epoch in ms
|
||||
parser = lambda do |date|
|
||||
if /\d+/ === date || date.is_a?(Numeric)
|
||||
raise "Invalid UNIX epoch value '#{date}'" unless /^\d+$/ === date || date.is_a?(Numeric)
|
||||
date.to_i
|
||||
else
|
||||
raise "Invalid UNIX epoch value '#{date}'"
|
||||
end
|
||||
end
|
||||
when "TAI64N" # TAI64 with nanoseconds, -10000 accounts for leap seconds
|
||||
joda_instant = org.joda.time.Instant.java_class.constructor(Java::long).method(:new_instance)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue