File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3,10 +3,11 @@ module RDF; class Literal
33 # A date literal.
44 #
55 # @see http://www.w3.org/TR/xmlschema11-2/#date
6+ # @see https://www.w3.org/TR/xmlschema11-2/#rf-lexicalMappings-datetime
67 # @since 0.2.1
78 class Date < Temporal
89 DATATYPE = RDF ::URI ( "http://www.w3.org/2001/XMLSchema#date" )
9- GRAMMAR = %r(\A (-? \d {4}- \d {2}- \d {2 })((?:[ \+ \- ] \d {2}: \d {2})|UTC|GMT|Z)? \Z ) . freeze
10+ GRAMMAR = %r(\A (#{ YEARFRAG } - #{ MONTHFRAG } - #{ DAYFRAG } )(#{ TZFRAG } )? \z ) . freeze
1011 FORMAT = '%Y-%m-%d' . freeze
1112
1213 ##
Original file line number Diff line number Diff line change @@ -3,10 +3,22 @@ module RDF; class Literal
33 # A date/time literal.
44 #
55 # @see http://www.w3.org/TR/xmlschema11-2/#dateTime
6+ # @see https://www.w3.org/TR/xmlschema11-2/#rf-lexicalMappings-datetime
67 # @since 0.2.1
78 class DateTime < Temporal
89 DATATYPE = RDF ::URI ( "http://www.w3.org/2001/XMLSchema#dateTime" )
9- GRAMMAR = %r(\A (-?(?:\d {4}|[1-9]\d {4,})-\d {2}-\d {2}T\d {2}:\d {2}:\d {2}(?:\. \d +)?)((?:[\+ \- ]\d {2}:\d {2})|UTC|GMT|Z)?\Z ) . freeze
10+ GRAMMAR = %r(\A
11+ (#{ YEARFRAG }
12+ -#{ MONTHFRAG }
13+ -#{ DAYFRAG }
14+ T
15+ (?:
16+ (?:
17+ #{ HOURFRAG }
18+ :#{ MINUTEFRAG }
19+ :#{ SECONDFRAG } )
20+ | #{ EODFRAG } ))
21+ (#{ TZFRAG } )?\z )x . freeze
1022 FORMAT = '%Y-%m-%dT%H:%M:%S.%L' . freeze
1123
1224 ##
Original file line number Diff line number Diff line change @@ -10,6 +10,15 @@ class Temporal < Literal
1010 |(?:(?<si>-)?PT(?<hr>\d {1,2})H(?:(?<mi>\d {1,2})M)?)
1111 \z )x . freeze
1212
13+ YEARFRAG = %r(-?(?:(?:[1-9]\d {3,})|(?:0\d {3})))
14+ MONTHFRAG = %r((?:(?:0[1-9])|(?:1[0-2])))
15+ DAYFRAG = %r((?:(?:0[1-9])|(?:[12]\d )|(?:3[01])))
16+ HOURFRAG = %r((?:[01]\d )|(?:2[0-3]))
17+ MINUTEFRAG = %r([0-5]\d )
18+ SECONDFRAG = %r([0-5]\d (?:\. \d +)?)
19+ EODFRAG = %r(24:00:00(?:\. 0+)?)
20+ TZFRAG = %r((?:[\+ \- ]\d {2}:\d {2})|UTC|GMT|Z)
21+
1322 ##
1423 # Compares this literal to `other` for sorting purposes.
1524 #
Original file line number Diff line number Diff line change @@ -8,10 +8,11 @@ module RDF; class Literal
88 # following time zone indicator.
99 #
1010 # @see http://www.w3.org/TR/xmlschema11-2/#time
11+ # @see https://www.w3.org/TR/xmlschema11-2/#rf-lexicalMappings-datetime
1112 # @since 0.2.1
1213 class Time < Temporal
1314 DATATYPE = RDF ::URI ( "http://www.w3.org/2001/XMLSchema#time" )
14- GRAMMAR = %r(\A (\d {2}: \d {2}: \d {2}(?: \. \d +)?)((?:[ \+ \- ] \d {2}: \d {2})|UTC|GMT|Z)? \Z ) . freeze
15+ GRAMMAR = %r(\A ((?: #{ HOURFRAG } : #{ MINUTEFRAG } : #{ SECONDFRAG } )| #{ EODFRAG } )( #{ TZFRAG } )? \z ) . freeze
1516 FORMAT = '%H:%M:%S.%L' . freeze
1617
1718 ##
You can’t perform that action at this time.
0 commit comments