Class: Fluent::TextParser::StdFormatTimeParser
- Inherits:
-
TimeParser
- Object
- TimeParser
- Fluent::TextParser::StdFormatTimeParser
- Defined in:
- lib/fluent/plugin/parser_jsonish.rb
Instance Method Summary collapse
-
#initialize(time_format) ⇒ StdFormatTimeParser
constructor
Extend the standard TimeParser to be able to use methods for standard formats – in particular, for formats which can be represented by muliple hard-coded formats.
Constructor Details
#initialize(time_format) ⇒ StdFormatTimeParser
Extend the standard TimeParser to be able to use methods for standard formats – in particular, for formats which can be represented by muliple hard-coded formats. For instance, the iso8601 format can be represented by either of the following formats (probably more) which are not interchangable as arguments to strptime – whether or not the tiemstamp has millisecond precision must be treated as two distinct formats if the available iso8601 method is not used:
-
‘%y-%m-%dT%H:%M:%S%Z’ (no fractional seconds)
-
‘%y-%m-%dT%H:%M:%S.%L%Z’ (fractional seconds)
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/fluent/plugin/parser_jsonish.rb', line 17 def initialize(time_format) if not time_format.nil? and time_format.empty? # Set a reasonable default. time_format = 'iso8601' end if not time_format.nil? and not /%/.match(time_format) super(nil) @parser = Proc.new { |v| Time.method(time_format).call(v) } else super(time_format) end end |