Report abuse
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
|
require 'rubygems'
require 'date'
require 'time'
require 'spec'
class Date
def self.iso8601(a_string)
case a_string.length
when 5
if a_string =~ /^([\+-]\d{4})$/
Date.new($1.to_i)
else
nil
end
when 7
if a_string =~ /(\d{4})-(\d{2})/ Date.new($1.to_i, $2.to_i)
elsif a_string =~ /\d{4}W\d{2}/ Date.new($1.to_i, 0, $2.to_i*7)
elsif a_string =~ /\d{4}\d{3}/ Date.new($1.to_i, 0, $2.to_i)
end
when 8
when 10
end
end
end
class Time
def self.iso8601(a_string)
nil
end
end
context 'ISO 8601 Dates' do
specify 'should parse +YYYY' do
date = Date.iso8601('+2007')
date.year.should == 2007
date = Date.iso8601('-0500')
date.year.should == -500
end
specify 'should parse YYYY-MM-DD' do
date = Date.iso8601('2006-12-18')
date.year.should == 2006
date.month.should == 12
date.day.should == 18
end
specify 'should parse YYYY-MM' do
date = Date.iso8601('2006-12')
date.year.should == 2006
date.month.should == 12
end
specify 'should parse YYYYMMDD' do
date = Date.iso8601('20061218')
date.year.should == 2006
date.month.should == 12
end
specify 'should parse YYYY-Www' do
end
specify 'should parse YYYYWww' do
end
specify 'should parse YYYY-Www-D' do
end
specify 'should parse YYYYWwwD' do
end
specify 'should parse YYYY-DDD' do
end
specify 'should parse YYYYDDD' do
end
end
context 'ISO 8601 Times' do
specify 'should parse hh:mm:ss' do
end
specify 'should parse hhmmss' do
end
specify 'should parse hh:mm' do
end
specify 'should parse hhmm' do
end
specify 'should parse hh' do
end
specify 'should parse <time>Z' do
end
specify 'should parse <time>±hh:mm:ss' do
end
specify 'should parse <time>±hhmmss' do
end
specify 'should parse <time>±hh:mm' do
end
specify 'should parse <time>±hhmm' do
end
specify 'should parse <time>±hh' do
end
end
context 'ISO 8601 Date/Times' do
specify 'should parse <date>T<time>' do
end
end
|