Class: Yabeda::Rack::Queue::HeaderTimestampParser
- Inherits:
-
Object
- Object
- Yabeda::Rack::Queue::HeaderTimestampParser
- Defined in:
- lib/yabeda/rack/queue/header_timestamp_parser.rb
Constant Summary collapse
- MIN_EPOCH =
Time.utc(2000, 1, 1).to_f
- FUTURE_TOLERANCE =
30.0- DIVISORS =
[1_000_000.0, 1_000.0, 1.0].freeze
- NUMBER_RE =
/[+-]?(?:\d+(?:\.\d+)?|\.\d+)/- T_EQUALS_RE =
/t\s*=\s*(#{NUMBER_RE.source})/i
Instance Method Summary collapse
Instance Method Details
#parse(value, now:) ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'lib/yabeda/rack/queue/header_timestamp_parser.rb', line 13 def parse(value, now:) first = value.to_s.split(",", 2).first.to_s.strip return if first.empty? token = first[T_EQUALS_RE, 1] || first[NUMBER_RE, 0] normalize(Float(token), now) if token rescue ArgumentError, TypeError end |