edn-abnf 0.0.11 → 0.0.12

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4dd67fd4813a8adf98e4bbffd069e9d9e40a9c8d4c51c9f1ef1226497d3e7e9b
4
- data.tar.gz: 524e68b7bb39b5acb883ddcbbbf3afd6531dfbc3892abfdf7346e8a97452e51d
3
+ metadata.gz: f762b42f537b6298556bf2e2988c8612cd26d9315c980ddb9a5e355a678a40c5
4
+ data.tar.gz: 91b77ee973f2d4c23a6a9bb0344a16324e783c47861f7f0929dfd6322dd0f743
5
5
  SHA512:
6
- metadata.gz: 132445c4a4c05bd1ce60d552c0c6809df5c92cb850c79243cd26fd5552f5db73e3a1b93dbce1585cddec77ff764d33b1bfb7a868d1907dfa37145a1762530729
7
- data.tar.gz: e399041d7bf61d00d80fe824daeb72e8d008927cd8cd5958aedce23f100e53ecef2887393d0aca753bafc9fed1c4330bd8696ffdcd6a6e69829331efd28e8e22
6
+ metadata.gz: ecb6361fcf84f6de6d7e547093ec2de27d7cc69161d7717ee336db9b39b0b546ce50015dbcfb8ed64d81129d67acdbaa4eb0fcb64751c55fbe10996e9ca61fd1
7
+ data.tar.gz: 8f438a03ee42ea49f1d412b9fe249332acfae759be315a1c6e8f71304fb8159c9161f8267252e9e6f8f463577c2f4c55bfeafff33baae1da7f6c0752d6a131d9
data/edn-abnf.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "edn-abnf"
3
- s.version = "0.0.11"
3
+ s.version = "0.0.12"
4
4
  s.summary = "CDDL (Concise Data Definition Language) converters and miscellaneous tools"
5
5
  s.description = %q{edn-abnf implements converters and miscellaneous tools for CBOR EDN's ABNF}
6
6
  s.author = "Carsten Bormann"
@@ -0,0 +1,25 @@
1
+ require_relative "dtgrammar.rb"
2
+ require 'time'
3
+
4
+ # Using Time#iso8601 creates the following bugs:
5
+ # * dt'1970-01-01T10:00:00' is accepted and gives local time
6
+ # * dt'1970-01-01T10:00:00.0Z' gives an integer instead of a float
7
+ # Probably should copy over Time#xmlschema and fix that for us.
8
+
9
+ class CBOR_DIAG::App_dt
10
+ def self.decode(_, s)
11
+ parser = DTGRAMMARParser.new
12
+ ast = parser.parse(s)
13
+ if !ast
14
+ raise ArgumentError, "cbor-diagnostic: Parse Error in dt'#{s}':\n" << EDN.reason(parser, s)
15
+ end
16
+ # ast.ast
17
+
18
+ t = Time.iso8601(s)
19
+ if t.subsec != 0
20
+ t.to_f
21
+ else
22
+ t.to_i
23
+ end
24
+ end
25
+ end