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(app_prefix, s) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/cbor-diagnostic-app/dt.rb', line 10 def self.decode(app_prefix, 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) tv = if t.subsec != 0 t.to_f else t.to_i end case app_prefix when 'dt' tv when 'DT' CBOR::Tagged.new(1, tv) else fail app_prefix end end |