Class: CBOR_DIAG::App_dt
- Inherits:
-
Object
- Object
- CBOR_DIAG::App_dt
- Defined in:
- lib/cbor-diagnostic-app/dt.rb
Overview
Using Time#iso8601 creates the following bugs:
-
dt’1970-01-01T10:00:00’ is accepted and gives local time
-
dt’1970-01-01T10:00:00.0Z’ gives an integer instead of a float
Probably should copy over Time#xmlschema and fix that for us.
Class Method Summary collapse
Class Method Details
.decode(_, s) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/cbor-diagnostic-app/dt.rb', line 10 def self.decode(_, s) parser = DTGRAMMARParser.new ast = parser.parse(s) if !ast raise ArgumentError, "cbor-diagnostic: Parse Error in dt'#{s}':\n" << EDN.reason(parser, s) end # ast.ast t = Time.iso8601(s) if t.subsec != 0 t.to_f else t.to_i end end |