home_run 1.0.1-x86-mswin32-60 → 1.0.2-x86-mswin32-60
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +6 -0
- data/default.mspec +1 -1
- data/ext/date_ext/date_parser.c +356 -290
- data/ext/date_ext/date_parser.rl +31 -3
- data/lib/1.8/date_ext.so +0 -0
- data/lib/1.9/date_ext.so +0 -0
- data/spec/datetime/parse_spec.rb +15 -0
- metadata +4 -4
data/CHANGELOG
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
=== 1.0.2 (2011-03-18)
|
2
|
+
|
3
|
+
* Support fractional timestamps in the ISO date parser (funny-falcon)
|
4
|
+
|
5
|
+
* Support more variations in timezone formats in the ISO date parser (funny-falcon)
|
6
|
+
|
1
7
|
=== 1.0.1 (2011-02-28)
|
2
8
|
|
3
9
|
* Make #step with a 0 step value raise an ArgumentError (jeremyevans)
|
data/default.mspec
CHANGED
data/ext/date_ext/date_parser.c
CHANGED
@@ -12,6 +12,7 @@ extern int rhrd_encoding_index;
|
|
12
12
|
|
13
13
|
#define RHRR_ISO_TIME_SET 0x1
|
14
14
|
#define RHRR_ISO_ZONE_SET 0x2
|
15
|
+
#define RHRR_ISO_SEC_FRACTION_SET 0x4
|
15
16
|
|
16
17
|
#define RHRR_RFC_TIME_SET 0x1
|
17
18
|
#define RHRR_RFC_ZONE_SET 0x2
|
@@ -32,6 +33,7 @@ extern VALUE rhrd_sym_min;
|
|
32
33
|
extern VALUE rhrd_sym_mon;
|
33
34
|
extern VALUE rhrd_sym_offset;
|
34
35
|
extern VALUE rhrd_sym_sec;
|
36
|
+
extern VALUE rhrd_sym_sec_fraction;
|
35
37
|
extern VALUE rhrd_sym_wday;
|
36
38
|
extern VALUE rhrd_sym_year;
|
37
39
|
extern VALUE rhrd_sym_zone;
|
@@ -80,42 +82,45 @@ long rhrd__weekday_num(char * str) {
|
|
80
82
|
}
|
81
83
|
|
82
84
|
|
83
|
-
#line
|
85
|
+
#line 86 "date_parser.c"
|
84
86
|
static const char _date_parser_actions[] = {
|
85
87
|
0, 1, 0, 1, 1, 1, 2, 1,
|
86
88
|
3, 1, 4, 1, 5, 1, 6, 1,
|
87
|
-
7, 1,
|
88
|
-
|
89
|
-
|
90
|
-
23, 1,
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
89
|
+
7, 1, 8, 1, 11, 1, 12, 1,
|
90
|
+
13, 1, 14, 1, 15, 1, 16, 1,
|
91
|
+
17, 1, 18, 1, 19, 1, 20, 1,
|
92
|
+
23, 1, 25, 1, 26, 1, 27, 1,
|
93
|
+
28, 1, 29, 1, 30, 1, 31, 1,
|
94
|
+
33, 2, 0, 24, 2, 8, 11, 2,
|
95
|
+
9, 7, 2, 9, 8, 2, 10, 8,
|
96
|
+
2, 20, 23, 2, 21, 20, 2, 22,
|
97
|
+
20, 2, 31, 33, 2, 32, 31, 3,
|
98
|
+
9, 8, 11, 3, 10, 8, 11, 3,
|
99
|
+
21, 20, 23, 3, 22, 20, 23, 3,
|
100
|
+
32, 31, 33
|
97
101
|
};
|
98
102
|
|
99
103
|
static const short _date_parser_key_offsets[] = {
|
100
104
|
0, 0, 20, 22, 24, 26, 28, 30,
|
101
105
|
32, 34, 36, 40, 42, 44, 45, 47,
|
102
|
-
49, 50, 52, 54, 56, 58,
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
489,
|
106
|
+
49, 50, 52, 54, 56, 58, 60, 62,
|
107
|
+
64, 67, 69, 71, 73, 76, 79, 95,
|
108
|
+
99, 101, 102, 105, 107, 109, 111, 113,
|
109
|
+
116, 118, 119, 121, 123, 124, 126, 128,
|
110
|
+
130, 132, 134, 136, 138, 140, 142, 144,
|
111
|
+
146, 148, 152, 154, 158, 160, 164, 166,
|
112
|
+
168, 170, 172, 174, 176, 178, 182, 184,
|
113
|
+
186, 187, 194, 203, 205, 224, 228, 230,
|
114
|
+
236, 238, 240, 242, 244, 246, 247, 249,
|
115
|
+
251, 252, 254, 256, 258, 260, 262, 264,
|
116
|
+
266, 268, 270, 272, 274, 276, 278, 282,
|
117
|
+
284, 288, 290, 294, 296, 298, 300, 302,
|
118
|
+
304, 306, 327, 348, 350, 352, 354, 356,
|
119
|
+
360, 362, 366, 368, 370, 372, 374, 379,
|
120
|
+
382, 388, 394, 400, 403, 408, 415, 422,
|
121
|
+
429, 436, 443, 450, 457, 464, 469, 473,
|
122
|
+
476, 481, 486, 489, 495, 520, 545, 548,
|
123
|
+
551, 554, 561, 566
|
119
124
|
};
|
120
125
|
|
121
126
|
static const char _date_parser_trans_keys[] = {
|
@@ -126,49 +131,58 @@ static const char _date_parser_trans_keys[] = {
|
|
126
131
|
49, 57, 45, 47, 48, 51, 49, 50,
|
127
132
|
49, 57, 48, 57, 58, 48, 53, 48,
|
128
133
|
57, 58, 48, 53, 48, 57, 48, 57,
|
129
|
-
48, 57,
|
130
|
-
|
131
|
-
|
132
|
-
65, 68, 70, 74, 77, 78, 79, 83,
|
133
|
-
97, 100, 102, 106, 109, 110, 111, 115,
|
134
|
-
80, 85, 112, 117, 82, 114, 47, 45,
|
135
|
-
48, 57, 48, 57, 48, 57, 48, 57,
|
136
|
-
48, 57, 50, 48, 49, 48, 57, 58,
|
137
|
-
48, 53, 48, 57, 58, 48, 53, 48,
|
138
|
-
57, 48, 57, 48, 57, 48, 57, 48,
|
139
|
-
57, 48, 52, 71, 103, 69, 101, 67,
|
140
|
-
99, 69, 101, 66, 98, 65, 85, 97,
|
141
|
-
117, 78, 110, 76, 78, 108, 110, 65,
|
142
|
-
97, 82, 89, 114, 121, 79, 111, 86,
|
143
|
-
118, 67, 99, 84, 116, 69, 101, 80,
|
144
|
-
112, 48, 57, 48, 49, 50, 57, 82,
|
145
|
-
114, 73, 105, 44, 32, 48, 51, 9,
|
146
|
-
13, 49, 50, 32, 48, 51, 9, 13,
|
147
|
-
49, 50, 52, 57, 49, 57, 32, 65,
|
134
|
+
48, 57, 48, 57, 48, 57, 48, 52,
|
135
|
+
50, 48, 49, 48, 57, 48, 49, 48,
|
136
|
+
50, 48, 49, 57, 47, 48, 57, 65,
|
148
137
|
68, 70, 74, 77, 78, 79, 83, 97,
|
149
|
-
100, 102, 106, 109, 110, 111, 115,
|
150
|
-
|
151
|
-
45, 9, 13, 48, 57, 48, 57, 48,
|
152
|
-
57, 48, 57, 48, 57, 48, 57, 58,
|
153
|
-
48, 53, 48, 57, 58, 48, 53, 48,
|
138
|
+
100, 102, 106, 109, 110, 111, 115, 80,
|
139
|
+
85, 112, 117, 82, 114, 47, 45, 48,
|
154
140
|
57, 48, 57, 48, 57, 48, 57, 48,
|
155
|
-
57,
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
141
|
+
57, 50, 48, 49, 48, 57, 58, 48,
|
142
|
+
53, 48, 57, 58, 48, 53, 48, 57,
|
143
|
+
48, 57, 48, 57, 48, 57, 48, 57,
|
144
|
+
48, 52, 71, 103, 69, 101, 67, 99,
|
145
|
+
69, 101, 66, 98, 65, 85, 97, 117,
|
146
|
+
78, 110, 76, 78, 108, 110, 65, 97,
|
147
|
+
82, 89, 114, 121, 79, 111, 86, 118,
|
148
|
+
67, 99, 84, 116, 69, 101, 80, 112,
|
149
|
+
48, 57, 48, 49, 50, 57, 82, 114,
|
150
|
+
73, 105, 44, 32, 48, 51, 9, 13,
|
151
|
+
49, 50, 32, 48, 51, 9, 13, 49,
|
152
|
+
50, 52, 57, 49, 57, 32, 65, 68,
|
153
|
+
70, 74, 77, 78, 79, 83, 97, 100,
|
154
|
+
102, 106, 109, 110, 111, 115, 9, 13,
|
155
|
+
80, 85, 112, 117, 82, 114, 32, 45,
|
156
|
+
9, 13, 48, 57, 48, 57, 48, 57,
|
157
|
+
48, 57, 48, 57, 48, 57, 58, 48,
|
158
|
+
53, 48, 57, 58, 48, 53, 48, 57,
|
159
|
+
48, 57, 48, 57, 48, 57, 48, 57,
|
160
|
+
84, 116, 48, 52, 71, 103, 69, 101,
|
161
|
+
67, 99, 69, 101, 66, 98, 65, 85,
|
162
|
+
97, 117, 78, 110, 76, 78, 108, 110,
|
163
|
+
65, 97, 82, 89, 114, 121, 79, 111,
|
164
|
+
86, 118, 67, 99, 84, 116, 69, 101,
|
165
|
+
80, 112, 32, 65, 68, 70, 74, 77,
|
166
|
+
78, 79, 83, 97, 100, 102, 106, 109,
|
167
|
+
110, 111, 115, 9, 13, 48, 57, 32,
|
168
|
+
65, 68, 70, 74, 77, 78, 79, 83,
|
169
|
+
97, 100, 102, 106, 109, 110, 111, 115,
|
170
|
+
9, 13, 48, 49, 48, 57, 48, 49,
|
171
|
+
79, 111, 78, 110, 65, 85, 97, 117,
|
172
|
+
84, 116, 72, 85, 104, 117, 85, 117,
|
173
|
+
69, 101, 69, 101, 68, 100, 32, 84,
|
174
|
+
116, 9, 13, 32, 9, 13, 32, 50,
|
175
|
+
9, 13, 48, 49, 32, 43, 45, 46,
|
176
|
+
9, 13, 32, 58, 9, 13, 48, 57,
|
177
|
+
32, 9, 13, 32, 9, 13, 48, 57,
|
178
|
+
32, 43, 45, 9, 13, 48, 57, 32,
|
179
|
+
43, 45, 9, 13, 48, 57, 32, 43,
|
180
|
+
45, 9, 13, 48, 57, 32, 43, 45,
|
181
|
+
9, 13, 48, 57, 32, 43, 45, 9,
|
182
|
+
13, 48, 57, 32, 43, 45, 9, 13,
|
183
|
+
48, 57, 32, 43, 45, 9, 13, 48,
|
184
|
+
57, 32, 43, 45, 9, 13, 48, 57,
|
185
|
+
32, 43, 45, 9, 13, 32, 58, 9,
|
172
186
|
13, 32, 9, 13, 32, 43, 45, 9,
|
173
187
|
13, 32, 43, 45, 9, 13, 32, 9,
|
174
188
|
13, 32, 50, 9, 13, 48, 49, 32,
|
@@ -187,67 +201,70 @@ static const char _date_parser_trans_keys[] = {
|
|
187
201
|
static const char _date_parser_single_lengths[] = {
|
188
202
|
0, 14, 0, 0, 0, 0, 2, 2,
|
189
203
|
0, 2, 2, 0, 0, 1, 0, 0,
|
190
|
-
1, 0, 0, 0, 0,
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
0, 0, 0, 0,
|
195
|
-
2,
|
196
|
-
2, 2, 2, 2,
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
2,
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
3, 3
|
204
|
+
1, 0, 0, 0, 0, 0, 0, 0,
|
205
|
+
1, 0, 0, 0, 1, 1, 16, 4,
|
206
|
+
2, 1, 1, 0, 0, 0, 0, 1,
|
207
|
+
0, 1, 0, 0, 1, 0, 0, 0,
|
208
|
+
0, 0, 0, 0, 2, 2, 2, 2,
|
209
|
+
2, 4, 2, 4, 2, 4, 2, 2,
|
210
|
+
2, 2, 2, 2, 0, 0, 2, 2,
|
211
|
+
1, 3, 3, 0, 17, 4, 2, 2,
|
212
|
+
0, 0, 0, 0, 0, 1, 0, 0,
|
213
|
+
1, 0, 0, 0, 0, 0, 0, 2,
|
214
|
+
0, 2, 2, 2, 2, 2, 4, 2,
|
215
|
+
4, 2, 4, 2, 2, 2, 2, 2,
|
216
|
+
2, 17, 17, 0, 0, 2, 2, 4,
|
217
|
+
2, 4, 2, 2, 2, 2, 3, 1,
|
218
|
+
2, 4, 2, 1, 1, 3, 3, 3,
|
219
|
+
3, 3, 3, 3, 3, 3, 2, 1,
|
220
|
+
3, 3, 1, 2, 15, 15, 1, 1,
|
221
|
+
1, 5, 3, 3
|
207
222
|
};
|
208
223
|
|
209
224
|
static const char _date_parser_range_lengths[] = {
|
210
225
|
0, 3, 1, 1, 1, 1, 0, 0,
|
211
226
|
1, 0, 1, 1, 1, 0, 1, 1,
|
212
|
-
0, 1, 1, 1, 1,
|
213
|
-
1, 1, 1, 1, 1, 1,
|
214
|
-
0, 0,
|
215
|
-
1,
|
216
|
-
1, 1, 1, 1,
|
227
|
+
0, 1, 1, 1, 1, 1, 1, 1,
|
228
|
+
1, 1, 1, 1, 1, 1, 0, 0,
|
229
|
+
0, 0, 1, 1, 1, 1, 1, 1,
|
230
|
+
1, 0, 1, 1, 0, 1, 1, 1,
|
231
|
+
1, 1, 1, 1, 0, 0, 0, 0,
|
217
232
|
0, 0, 0, 0, 0, 0, 0, 0,
|
218
|
-
0, 0, 0, 0,
|
219
|
-
0,
|
220
|
-
|
221
|
-
|
222
|
-
|
233
|
+
0, 0, 0, 0, 1, 2, 0, 0,
|
234
|
+
0, 2, 3, 1, 1, 0, 0, 2,
|
235
|
+
1, 1, 1, 1, 1, 0, 1, 1,
|
236
|
+
0, 1, 1, 1, 1, 1, 1, 0,
|
237
|
+
1, 0, 0, 0, 0, 0, 0, 0,
|
223
238
|
0, 0, 0, 0, 0, 0, 0, 0,
|
224
|
-
0,
|
225
|
-
0, 0, 0, 0, 0, 0,
|
226
|
-
1, 2, 1,
|
227
|
-
|
228
|
-
1, 1
|
239
|
+
0, 2, 2, 1, 1, 0, 0, 0,
|
240
|
+
0, 0, 0, 0, 0, 0, 1, 1,
|
241
|
+
2, 1, 2, 1, 2, 2, 2, 2,
|
242
|
+
2, 2, 2, 2, 2, 1, 1, 1,
|
243
|
+
1, 1, 1, 2, 5, 5, 1, 1,
|
244
|
+
1, 1, 1, 1
|
229
245
|
};
|
230
246
|
|
231
247
|
static const short _date_parser_index_offsets[] = {
|
232
248
|
0, 0, 18, 20, 22, 24, 26, 29,
|
233
249
|
32, 34, 37, 41, 43, 45, 47, 49,
|
234
250
|
51, 53, 55, 57, 59, 61, 63, 65,
|
235
|
-
67,
|
236
|
-
|
237
|
-
|
238
|
-
139, 141, 143, 145, 147,
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
251
|
+
67, 70, 72, 74, 76, 79, 82, 99,
|
252
|
+
104, 107, 109, 112, 114, 116, 118, 120,
|
253
|
+
123, 125, 127, 129, 131, 133, 135, 137,
|
254
|
+
139, 141, 143, 145, 147, 150, 153, 156,
|
255
|
+
159, 162, 167, 170, 175, 178, 183, 186,
|
256
|
+
189, 192, 195, 198, 201, 203, 206, 209,
|
257
|
+
212, 214, 220, 227, 229, 248, 253, 256,
|
258
|
+
261, 263, 265, 267, 269, 271, 273, 275,
|
243
259
|
277, 279, 281, 283, 285, 287, 289, 291,
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
260
|
+
294, 296, 299, 302, 305, 308, 311, 316,
|
261
|
+
319, 324, 327, 332, 335, 338, 341, 344,
|
262
|
+
347, 350, 370, 390, 392, 394, 397, 400,
|
263
|
+
405, 408, 413, 416, 419, 422, 425, 430,
|
264
|
+
433, 438, 444, 449, 452, 456, 462, 468,
|
265
|
+
474, 480, 486, 492, 498, 504, 509, 513,
|
266
|
+
516, 521, 526, 529, 534, 555, 576, 579,
|
267
|
+
582, 585, 592, 597
|
251
268
|
};
|
252
269
|
|
253
270
|
static const unsigned char _date_parser_indicies[] = {
|
@@ -259,112 +276,124 @@ static const unsigned char _date_parser_indicies[] = {
|
|
259
276
|
1, 24, 1, 25, 1, 26, 1, 27,
|
260
277
|
1, 28, 1, 29, 1, 30, 1, 31,
|
261
278
|
1, 32, 1, 33, 1, 34, 1, 35,
|
262
|
-
1,
|
263
|
-
24, 1,
|
264
|
-
1, 40,
|
265
|
-
|
266
|
-
|
267
|
-
50,
|
279
|
+
1, 25, 1, 37, 36, 1, 24, 1,
|
280
|
+
24, 1, 19, 1, 13, 38, 1, 39,
|
281
|
+
14, 1, 40, 41, 42, 43, 44, 45,
|
282
|
+
46, 47, 40, 41, 42, 43, 44, 45,
|
283
|
+
46, 47, 1, 48, 49, 48, 49, 1,
|
284
|
+
50, 50, 1, 51, 1, 52, 53, 1,
|
268
285
|
54, 1, 55, 1, 56, 1, 57, 1,
|
269
|
-
58, 1, 60,
|
286
|
+
59, 58, 1, 60, 1, 61, 1, 62,
|
270
287
|
1, 63, 1, 64, 1, 65, 1, 66,
|
271
288
|
1, 67, 1, 68, 1, 69, 1, 70,
|
272
|
-
1,
|
273
|
-
|
274
|
-
1,
|
275
|
-
|
276
|
-
|
277
|
-
1,
|
278
|
-
|
279
|
-
|
280
|
-
80, 80, 1, 81,
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
289
|
+
1, 60, 1, 50, 50, 1, 71, 71,
|
290
|
+
1, 50, 50, 1, 72, 72, 1, 50,
|
291
|
+
50, 1, 73, 74, 73, 74, 1, 50,
|
292
|
+
50, 1, 50, 50, 50, 50, 1, 75,
|
293
|
+
75, 1, 50, 50, 50, 50, 1, 76,
|
294
|
+
76, 1, 50, 50, 1, 77, 77, 1,
|
295
|
+
50, 50, 1, 78, 78, 1, 50, 50,
|
296
|
+
1, 38, 1, 38, 13, 1, 79, 79,
|
297
|
+
1, 80, 80, 1, 81, 1, 82, 83,
|
298
|
+
85, 81, 84, 1, 82, 83, 87, 81,
|
299
|
+
86, 88, 1, 88, 1, 88, 89, 90,
|
300
|
+
91, 92, 93, 94, 95, 96, 89, 90,
|
301
|
+
91, 92, 93, 94, 95, 96, 88, 1,
|
302
|
+
97, 98, 97, 98, 1, 99, 99, 1,
|
303
|
+
99, 100, 99, 101, 1, 102, 1, 103,
|
287
304
|
1, 104, 1, 105, 1, 106, 1, 107,
|
288
305
|
1, 108, 1, 109, 1, 110, 1, 111,
|
289
306
|
1, 112, 1, 113, 1, 114, 1, 115,
|
290
|
-
1, 116, 1, 117,
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
1,
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
135, 136,
|
310
|
-
|
311
|
-
141, 141, 140,
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
1,
|
320
|
-
|
321
|
-
|
307
|
+
1, 116, 1, 117, 117, 1, 106, 1,
|
308
|
+
99, 99, 1, 118, 118, 1, 99, 99,
|
309
|
+
1, 119, 119, 1, 99, 99, 1, 120,
|
310
|
+
121, 120, 121, 1, 99, 99, 1, 99,
|
311
|
+
99, 99, 99, 1, 122, 122, 1, 99,
|
312
|
+
99, 99, 99, 1, 123, 123, 1, 99,
|
313
|
+
99, 1, 124, 124, 1, 99, 99, 1,
|
314
|
+
125, 125, 1, 99, 99, 1, 88, 89,
|
315
|
+
90, 91, 92, 93, 94, 95, 96, 89,
|
316
|
+
90, 91, 92, 93, 94, 95, 96, 88,
|
317
|
+
88, 1, 88, 89, 90, 91, 92, 93,
|
318
|
+
94, 95, 96, 89, 90, 91, 92, 93,
|
319
|
+
94, 95, 96, 88, 88, 1, 88, 1,
|
320
|
+
88, 1, 126, 126, 1, 80, 80, 1,
|
321
|
+
127, 126, 127, 126, 1, 80, 80, 1,
|
322
|
+
128, 129, 128, 129, 1, 80, 80, 1,
|
323
|
+
80, 80, 1, 130, 130, 1, 80, 80,
|
324
|
+
1, 132, 133, 133, 131, 1, 131, 131,
|
325
|
+
1, 131, 37, 131, 36, 1, 134, 135,
|
326
|
+
135, 136, 134, 1, 137, 139, 137, 138,
|
327
|
+
1, 137, 137, 1, 137, 137, 138, 1,
|
328
|
+
140, 141, 141, 140, 142, 1, 140, 141,
|
329
|
+
141, 140, 143, 1, 140, 141, 141, 140,
|
330
|
+
144, 1, 140, 141, 141, 140, 145, 1,
|
331
|
+
140, 141, 141, 140, 146, 1, 140, 141,
|
332
|
+
141, 140, 147, 1, 140, 141, 141, 140,
|
333
|
+
148, 1, 140, 141, 141, 140, 149, 1,
|
334
|
+
140, 141, 141, 140, 1, 150, 151, 150,
|
335
|
+
1, 150, 150, 1, 152, 153, 153, 152,
|
336
|
+
1, 154, 153, 153, 154, 1, 155, 155,
|
337
|
+
1, 105, 157, 105, 156, 1, 158, 159,
|
338
|
+
159, 161, 161, 162, 161, 161, 163, 161,
|
339
|
+
161, 162, 161, 161, 163, 158, 160, 160,
|
340
|
+
160, 160, 1, 164, 159, 159, 161, 161,
|
341
|
+
162, 161, 161, 163, 161, 161, 162, 161,
|
342
|
+
161, 163, 164, 160, 160, 160, 160, 1,
|
343
|
+
165, 165, 1, 166, 166, 1, 167, 167,
|
344
|
+
1, 167, 168, 168, 168, 168, 167, 1,
|
345
|
+
167, 168, 168, 167, 1, 167, 117, 117,
|
346
|
+
167, 1, 0
|
322
347
|
};
|
323
348
|
|
324
349
|
static const unsigned char _date_parser_trans_targs[] = {
|
325
|
-
1, 0, 2,
|
326
|
-
|
327
|
-
7, 8,
|
328
|
-
|
329
|
-
20,
|
330
|
-
31,
|
331
|
-
|
332
|
-
38,
|
333
|
-
45, 46,
|
334
|
-
|
335
|
-
72, 73, 74, 75,
|
336
|
-
|
337
|
-
|
338
|
-
83,
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
350
|
+
1, 0, 2, 28, 68, 69, 3, 70,
|
351
|
+
117, 119, 121, 124, 3, 4, 5, 6,
|
352
|
+
7, 8, 27, 9, 10, 11, 25, 26,
|
353
|
+
126, 13, 14, 15, 16, 17, 18, 129,
|
354
|
+
20, 130, 131, 133, 12, 23, 29, 30,
|
355
|
+
31, 53, 55, 57, 60, 62, 64, 66,
|
356
|
+
32, 52, 33, 34, 35, 36, 36, 37,
|
357
|
+
38, 142, 40, 51, 41, 42, 43, 44,
|
358
|
+
45, 46, 144, 48, 49, 50, 146, 54,
|
359
|
+
56, 58, 59, 61, 63, 65, 67, 71,
|
360
|
+
72, 73, 74, 75, 115, 116, 113, 114,
|
361
|
+
76, 77, 98, 100, 102, 105, 107, 109,
|
362
|
+
111, 78, 97, 79, 80, 81, 81, 82,
|
363
|
+
83, 147, 85, 86, 87, 88, 89, 90,
|
364
|
+
148, 92, 93, 94, 150, 152, 99, 101,
|
365
|
+
103, 104, 106, 108, 110, 112, 118, 120,
|
366
|
+
122, 123, 125, 127, 128, 24, 127, 19,
|
367
|
+
22, 127, 21, 132, 127, 19, 134, 135,
|
368
|
+
136, 137, 138, 139, 140, 141, 143, 39,
|
369
|
+
145, 47, 145, 143, 84, 96, 149, 91,
|
370
|
+
152, 153, 154, 155, 149, 151, 151, 151,
|
371
|
+
95
|
345
372
|
};
|
346
373
|
|
347
374
|
static const char _date_parser_trans_actions[] = {
|
348
|
-
0, 0, 1,
|
349
|
-
|
375
|
+
0, 0, 1, 57, 57, 57, 1, 21,
|
376
|
+
21, 21, 21, 21, 0, 0, 0, 0,
|
350
377
|
0, 3, 3, 0, 0, 5, 5, 5,
|
351
378
|
0, 0, 0, 9, 0, 0, 11, 0,
|
352
|
-
0, 0, 0, 0,
|
353
|
-
|
354
|
-
|
355
|
-
0, 0,
|
356
|
-
0,
|
379
|
+
0, 0, 0, 0, 7, 7, 0, 0,
|
380
|
+
41, 41, 41, 41, 41, 41, 41, 41,
|
381
|
+
0, 0, 0, 0, 43, 43, 0, 0,
|
382
|
+
0, 0, 45, 45, 0, 0, 47, 0,
|
383
|
+
0, 49, 0, 0, 0, 0, 0, 0,
|
384
|
+
0, 0, 0, 0, 0, 0, 0, 0,
|
385
|
+
0, 0, 23, 23, 23, 23, 23, 23,
|
386
|
+
0, 25, 25, 25, 25, 25, 25, 25,
|
387
|
+
25, 0, 0, 0, 27, 27, 0, 0,
|
388
|
+
0, 0, 0, 0, 31, 0, 0, 33,
|
357
389
|
0, 0, 0, 0, 0, 0, 0, 0,
|
358
|
-
0, 0, 0, 21, 21, 21, 21, 21,
|
359
|
-
21, 0, 23, 23, 23, 23, 23, 23,
|
360
|
-
23, 23, 0, 0, 0, 25, 25, 0,
|
361
|
-
0, 0, 0, 0, 0, 29, 0, 0,
|
362
|
-
31, 0, 0, 0, 0, 0, 0, 0,
|
363
390
|
0, 0, 0, 0, 0, 0, 0, 0,
|
364
|
-
0, 0, 0, 0, 0, 0,
|
365
|
-
13,
|
366
|
-
|
367
|
-
|
391
|
+
0, 0, 0, 0, 0, 0, 17, 15,
|
392
|
+
13, 69, 0, 0, 66, 63, 0, 0,
|
393
|
+
0, 0, 0, 0, 0, 0, 0, 0,
|
394
|
+
53, 51, 0, 84, 29, 29, 37, 35,
|
395
|
+
35, 35, 35, 35, 0, 75, 0, 78,
|
396
|
+
0
|
368
397
|
};
|
369
398
|
|
370
399
|
static const char _date_parser_eof_actions[] = {
|
@@ -383,20 +412,21 @@ static const char _date_parser_eof_actions[] = {
|
|
383
412
|
0, 0, 0, 0, 0, 0, 0, 0,
|
384
413
|
0, 0, 0, 0, 0, 0, 0, 0,
|
385
414
|
0, 0, 0, 0, 0, 0, 0, 0,
|
386
|
-
0, 0, 0, 0, 0, 0,
|
387
|
-
|
388
|
-
|
389
|
-
|
415
|
+
0, 0, 0, 0, 0, 0, 19, 19,
|
416
|
+
19, 60, 91, 91, 91, 87, 87, 87,
|
417
|
+
87, 87, 87, 87, 87, 87, 55, 55,
|
418
|
+
81, 55, 103, 39, 72, 39, 95, 39,
|
419
|
+
99, 99, 99, 99
|
390
420
|
};
|
391
421
|
|
392
422
|
static const int date_parser_start = 1;
|
393
|
-
static const int date_parser_first_final =
|
423
|
+
static const int date_parser_first_final = 126;
|
394
424
|
static const int date_parser_error = 0;
|
395
425
|
|
396
426
|
static const int date_parser_en_main = 1;
|
397
427
|
|
398
428
|
|
399
|
-
#line
|
429
|
+
#line 195 "date_parser.rl"
|
400
430
|
|
401
431
|
|
402
432
|
VALUE rhrd__ragel_parse(char * p, long len) {
|
@@ -412,6 +442,7 @@ VALUE rhrd__ragel_parse(char * p, long len) {
|
|
412
442
|
long hour = 0;
|
413
443
|
long minute = 0;
|
414
444
|
long second = 0;
|
445
|
+
double sec_fraction = 0;
|
415
446
|
|
416
447
|
VALUE rzone;
|
417
448
|
char * zone = NULL;
|
@@ -425,6 +456,8 @@ VALUE rhrd__ragel_parse(char * p, long len) {
|
|
425
456
|
char * t_iso_hour= NULL;
|
426
457
|
char * t_iso_minute = NULL;
|
427
458
|
char * t_iso_second = NULL;
|
459
|
+
char * t_iso_sec_fraction = NULL;
|
460
|
+
char * t_iso_sec_fraction_end = NULL;
|
428
461
|
char * t_iso_zone = NULL;
|
429
462
|
char * t_iso_zone_end = NULL;
|
430
463
|
|
@@ -456,14 +489,14 @@ VALUE rhrd__ragel_parse(char * p, long len) {
|
|
456
489
|
eof = pe;
|
457
490
|
|
458
491
|
|
459
|
-
#line
|
492
|
+
#line 493 "date_parser.c"
|
460
493
|
{
|
461
494
|
cs = date_parser_start;
|
462
495
|
}
|
463
496
|
|
464
|
-
#line
|
497
|
+
#line 257 "date_parser.rl"
|
465
498
|
|
466
|
-
#line
|
499
|
+
#line 500 "date_parser.c"
|
467
500
|
{
|
468
501
|
int _klen;
|
469
502
|
unsigned int _trans;
|
@@ -538,134 +571,145 @@ _match:
|
|
538
571
|
switch ( *_acts++ )
|
539
572
|
{
|
540
573
|
case 0:
|
541
|
-
#line
|
574
|
+
#line 91 "date_parser.rl"
|
542
575
|
{ t_iso_year = p; }
|
543
576
|
break;
|
544
577
|
case 1:
|
545
|
-
#line
|
578
|
+
#line 92 "date_parser.rl"
|
546
579
|
{ t_iso_month = p; }
|
547
580
|
break;
|
548
581
|
case 2:
|
549
|
-
#line
|
582
|
+
#line 93 "date_parser.rl"
|
550
583
|
{ t_iso_day = p; }
|
551
584
|
break;
|
552
585
|
case 3:
|
553
|
-
#line
|
586
|
+
#line 94 "date_parser.rl"
|
554
587
|
{ t_iso_hour = p; }
|
555
588
|
break;
|
556
589
|
case 4:
|
557
|
-
#line
|
590
|
+
#line 95 "date_parser.rl"
|
558
591
|
{ t_iso_minute = p; }
|
559
592
|
break;
|
560
593
|
case 5:
|
561
|
-
#line
|
594
|
+
#line 96 "date_parser.rl"
|
562
595
|
{ t_iso_second = p; }
|
563
596
|
break;
|
564
597
|
case 6:
|
565
|
-
#line
|
566
|
-
{
|
598
|
+
#line 97 "date_parser.rl"
|
599
|
+
{ t_iso_sec_fraction = p; }
|
567
600
|
break;
|
568
601
|
case 7:
|
569
|
-
#line
|
570
|
-
{
|
602
|
+
#line 98 "date_parser.rl"
|
603
|
+
{ t_iso_zone = p; }
|
571
604
|
break;
|
572
605
|
case 8:
|
573
|
-
#line
|
606
|
+
#line 100 "date_parser.rl"
|
607
|
+
{ iso_state |= RHRR_ISO_TIME_SET; }
|
608
|
+
break;
|
609
|
+
case 9:
|
610
|
+
#line 101 "date_parser.rl"
|
611
|
+
{
|
612
|
+
t_iso_sec_fraction_end = p;
|
613
|
+
iso_state |= RHRR_ISO_SEC_FRACTION_SET;
|
614
|
+
}
|
615
|
+
break;
|
616
|
+
case 10:
|
617
|
+
#line 105 "date_parser.rl"
|
574
618
|
{
|
575
619
|
t_iso_zone_end = p;
|
576
620
|
iso_state |= RHRR_ISO_ZONE_SET;
|
577
621
|
}
|
578
622
|
break;
|
579
|
-
case
|
580
|
-
#line
|
623
|
+
case 12:
|
624
|
+
#line 128 "date_parser.rl"
|
581
625
|
{ t_rfc_wday = p; }
|
582
626
|
break;
|
583
|
-
case
|
584
|
-
#line
|
627
|
+
case 13:
|
628
|
+
#line 129 "date_parser.rl"
|
585
629
|
{ t_rfc_day = p; }
|
586
630
|
break;
|
587
|
-
case
|
588
|
-
#line
|
631
|
+
case 14:
|
632
|
+
#line 130 "date_parser.rl"
|
589
633
|
{ t_rfc_month = p; }
|
590
634
|
break;
|
591
|
-
case
|
592
|
-
#line
|
635
|
+
case 15:
|
636
|
+
#line 131 "date_parser.rl"
|
593
637
|
{ t_rfc_year = p; }
|
594
638
|
break;
|
595
|
-
case
|
596
|
-
#line
|
639
|
+
case 16:
|
640
|
+
#line 132 "date_parser.rl"
|
597
641
|
{ t_rfc_hour = p; }
|
598
642
|
break;
|
599
|
-
case
|
600
|
-
#line
|
643
|
+
case 17:
|
644
|
+
#line 133 "date_parser.rl"
|
601
645
|
{ t_rfc_minute = p; }
|
602
646
|
break;
|
603
|
-
case
|
604
|
-
#line
|
647
|
+
case 18:
|
648
|
+
#line 134 "date_parser.rl"
|
605
649
|
{ t_rfc_second = p; }
|
606
650
|
break;
|
607
|
-
case
|
608
|
-
#line
|
651
|
+
case 19:
|
652
|
+
#line 135 "date_parser.rl"
|
609
653
|
{ t_rfc_zone = p; }
|
610
654
|
break;
|
611
|
-
case
|
612
|
-
#line
|
655
|
+
case 20:
|
656
|
+
#line 137 "date_parser.rl"
|
613
657
|
{ rfc_state |= RHRR_RFC_TIME_SET; }
|
614
658
|
break;
|
615
|
-
case
|
616
|
-
#line
|
659
|
+
case 21:
|
660
|
+
#line 138 "date_parser.rl"
|
617
661
|
{
|
618
662
|
t_rfc_zone_end = p;
|
619
663
|
rfc_state |= RHRR_RFC_ZONE_SET | RHRR_RFC_ZONE_NUM_SET;
|
620
664
|
}
|
621
665
|
break;
|
622
|
-
case
|
623
|
-
#line
|
666
|
+
case 22:
|
667
|
+
#line 142 "date_parser.rl"
|
624
668
|
{
|
625
669
|
t_rfc_zone_end = p;
|
626
670
|
rfc_state |= RHRR_RFC_ZONE_SET | RHRR_RFC_ZONE_NAME_SET;
|
627
671
|
}
|
628
672
|
break;
|
629
|
-
case
|
630
|
-
#line
|
673
|
+
case 24:
|
674
|
+
#line 165 "date_parser.rl"
|
631
675
|
{ t_clf_day = p; }
|
632
676
|
break;
|
633
|
-
case
|
634
|
-
#line
|
677
|
+
case 25:
|
678
|
+
#line 166 "date_parser.rl"
|
635
679
|
{ t_clf_month = p; }
|
636
680
|
break;
|
637
|
-
case
|
638
|
-
#line
|
681
|
+
case 26:
|
682
|
+
#line 167 "date_parser.rl"
|
639
683
|
{ t_clf_year = p; }
|
640
684
|
break;
|
641
|
-
case
|
642
|
-
#line
|
685
|
+
case 27:
|
686
|
+
#line 168 "date_parser.rl"
|
643
687
|
{ t_clf_hour = p; }
|
644
688
|
break;
|
645
|
-
case
|
646
|
-
#line
|
689
|
+
case 28:
|
690
|
+
#line 169 "date_parser.rl"
|
647
691
|
{ t_clf_minute = p; }
|
648
692
|
break;
|
649
|
-
case
|
650
|
-
#line
|
693
|
+
case 29:
|
694
|
+
#line 170 "date_parser.rl"
|
651
695
|
{ t_clf_second = p; }
|
652
696
|
break;
|
653
|
-
case
|
654
|
-
#line
|
697
|
+
case 30:
|
698
|
+
#line 171 "date_parser.rl"
|
655
699
|
{ t_clf_zone = p; }
|
656
700
|
break;
|
657
|
-
case
|
658
|
-
#line
|
701
|
+
case 31:
|
702
|
+
#line 173 "date_parser.rl"
|
659
703
|
{ clf_state |= RHRR_CLF_TIME_SET; }
|
660
704
|
break;
|
661
|
-
case
|
662
|
-
#line
|
705
|
+
case 32:
|
706
|
+
#line 174 "date_parser.rl"
|
663
707
|
{
|
664
708
|
t_clf_zone_end = p;
|
665
709
|
clf_state |= RHRR_CLF_ZONE_SET;
|
666
710
|
}
|
667
711
|
break;
|
668
|
-
#line
|
712
|
+
#line 713 "date_parser.c"
|
669
713
|
}
|
670
714
|
}
|
671
715
|
|
@@ -681,59 +725,66 @@ _again:
|
|
681
725
|
unsigned int __nacts = (unsigned int) *__acts++;
|
682
726
|
while ( __nacts-- > 0 ) {
|
683
727
|
switch ( *__acts++ ) {
|
684
|
-
case
|
685
|
-
#line
|
728
|
+
case 8:
|
729
|
+
#line 100 "date_parser.rl"
|
686
730
|
{ iso_state |= RHRR_ISO_TIME_SET; }
|
687
731
|
break;
|
688
|
-
case
|
689
|
-
#line
|
732
|
+
case 9:
|
733
|
+
#line 101 "date_parser.rl"
|
734
|
+
{
|
735
|
+
t_iso_sec_fraction_end = p;
|
736
|
+
iso_state |= RHRR_ISO_SEC_FRACTION_SET;
|
737
|
+
}
|
738
|
+
break;
|
739
|
+
case 10:
|
740
|
+
#line 105 "date_parser.rl"
|
690
741
|
{
|
691
742
|
t_iso_zone_end = p;
|
692
743
|
iso_state |= RHRR_ISO_ZONE_SET;
|
693
744
|
}
|
694
745
|
break;
|
695
|
-
case
|
696
|
-
#line
|
746
|
+
case 11:
|
747
|
+
#line 109 "date_parser.rl"
|
697
748
|
{ parsers |= RHRR_ISO_PARSER; }
|
698
749
|
break;
|
699
|
-
case
|
700
|
-
#line
|
750
|
+
case 20:
|
751
|
+
#line 137 "date_parser.rl"
|
701
752
|
{ rfc_state |= RHRR_RFC_TIME_SET; }
|
702
753
|
break;
|
703
|
-
case
|
704
|
-
#line
|
754
|
+
case 21:
|
755
|
+
#line 138 "date_parser.rl"
|
705
756
|
{
|
706
757
|
t_rfc_zone_end = p;
|
707
758
|
rfc_state |= RHRR_RFC_ZONE_SET | RHRR_RFC_ZONE_NUM_SET;
|
708
759
|
}
|
709
760
|
break;
|
710
|
-
case
|
711
|
-
#line
|
761
|
+
case 22:
|
762
|
+
#line 142 "date_parser.rl"
|
712
763
|
{
|
713
764
|
t_rfc_zone_end = p;
|
714
765
|
rfc_state |= RHRR_RFC_ZONE_SET | RHRR_RFC_ZONE_NAME_SET;
|
715
766
|
}
|
716
767
|
break;
|
717
|
-
case
|
718
|
-
#line
|
768
|
+
case 23:
|
769
|
+
#line 146 "date_parser.rl"
|
719
770
|
{ parsers |= RHRR_RFC_PARSER; }
|
720
771
|
break;
|
721
|
-
case
|
722
|
-
#line
|
772
|
+
case 31:
|
773
|
+
#line 173 "date_parser.rl"
|
723
774
|
{ clf_state |= RHRR_CLF_TIME_SET; }
|
724
775
|
break;
|
725
|
-
case
|
726
|
-
#line
|
776
|
+
case 32:
|
777
|
+
#line 174 "date_parser.rl"
|
727
778
|
{
|
728
779
|
t_clf_zone_end = p;
|
729
780
|
clf_state |= RHRR_CLF_ZONE_SET;
|
730
781
|
}
|
731
782
|
break;
|
732
|
-
case
|
733
|
-
#line
|
783
|
+
case 33:
|
784
|
+
#line 178 "date_parser.rl"
|
734
785
|
{ parsers |= RHRR_CLF_PARSER; }
|
735
786
|
break;
|
736
|
-
#line
|
787
|
+
#line 788 "date_parser.c"
|
737
788
|
}
|
738
789
|
}
|
739
790
|
}
|
@@ -741,7 +792,7 @@ _again:
|
|
741
792
|
_out: {}
|
742
793
|
}
|
743
794
|
|
744
|
-
#line
|
795
|
+
#line 258 "date_parser.rl"
|
745
796
|
|
746
797
|
switch(parsers) {
|
747
798
|
case RHRR_ISO_PARSER:
|
@@ -754,10 +805,22 @@ _again:
|
|
754
805
|
minute = atol(t_iso_minute);
|
755
806
|
second = atol(t_iso_second);
|
756
807
|
state |= RHRR_HOUR_SET | RHRR_MINUTE_SET | RHRR_SECOND_SET;
|
808
|
+
if (iso_state & RHRR_ISO_SEC_FRACTION_SET) {
|
809
|
+
sec_fraction = atoi(t_iso_sec_fraction+1) / pow(10, t_iso_sec_fraction_end - t_iso_sec_fraction - 1);
|
810
|
+
state |= RHRR_SEC_FRACTION_SET;
|
811
|
+
}
|
757
812
|
if (iso_state & RHRR_ISO_ZONE_SET) {
|
758
813
|
zone = t_iso_zone;
|
759
814
|
zone_len = t_iso_zone_end - zone;
|
760
|
-
|
815
|
+
if (zone_len == 3) { /* case for postgresql +03 */
|
816
|
+
offset = atol(zone) * 3600;
|
817
|
+
} else if (zone_len == 6) { /* standart iso */
|
818
|
+
offset = atol(zone) * 3600 + atol(zone + 4) * 60;
|
819
|
+
} else if (zone_len == 5) { /* case for sqlite +0300 */
|
820
|
+
char hours[3] = { zone[1], zone[2], 0};
|
821
|
+
offset = atol(hours) * 3600 + atol(zone + 3) * 60;
|
822
|
+
offset *= (zone[0] == '-') ? -1 : 1;
|
823
|
+
}
|
761
824
|
state |= RHRR_ZONE_SET | RHRR_OFFSET_SET;
|
762
825
|
}
|
763
826
|
}
|
@@ -839,6 +902,9 @@ _again:
|
|
839
902
|
if(state & RHRR_SECOND_SET) {
|
840
903
|
rb_hash_aset(hash, rhrd_sym_sec, LONG2NUM(second));
|
841
904
|
}
|
905
|
+
if(state & RHRR_SEC_FRACTION_SET) {
|
906
|
+
rb_hash_aset(hash, rhrd_sym_sec_fraction, rb_float_new(sec_fraction));
|
907
|
+
}
|
842
908
|
if(state & RHRR_ZONE_SET) {
|
843
909
|
rzone = rb_str_new(zone, zone_len);
|
844
910
|
rb_hash_aset(hash, rhrd_sym_zone, rzone);
|
data/ext/date_ext/date_parser.rl
CHANGED
@@ -10,6 +10,7 @@ extern int rhrd_encoding_index;
|
|
10
10
|
|
11
11
|
#define RHRR_ISO_TIME_SET 0x1
|
12
12
|
#define RHRR_ISO_ZONE_SET 0x2
|
13
|
+
#define RHRR_ISO_SEC_FRACTION_SET 0x4
|
13
14
|
|
14
15
|
#define RHRR_RFC_TIME_SET 0x1
|
15
16
|
#define RHRR_RFC_ZONE_SET 0x2
|
@@ -30,6 +31,7 @@ extern VALUE rhrd_sym_min;
|
|
30
31
|
extern VALUE rhrd_sym_mon;
|
31
32
|
extern VALUE rhrd_sym_offset;
|
32
33
|
extern VALUE rhrd_sym_sec;
|
34
|
+
extern VALUE rhrd_sym_sec_fraction;
|
33
35
|
extern VALUE rhrd_sym_wday;
|
34
36
|
extern VALUE rhrd_sym_year;
|
35
37
|
extern VALUE rhrd_sym_zone;
|
@@ -92,9 +94,14 @@ long rhrd__weekday_num(char * str) {
|
|
92
94
|
action tag_iso_hour { t_iso_hour = p; }
|
93
95
|
action tag_iso_minute { t_iso_minute = p; }
|
94
96
|
action tag_iso_second { t_iso_second = p; }
|
97
|
+
action tag_iso_sec_fraction { t_iso_sec_fraction = p; }
|
95
98
|
action tag_iso_zone { t_iso_zone = p; }
|
96
99
|
|
97
100
|
action set_iso_time { iso_state |= RHRR_ISO_TIME_SET; }
|
101
|
+
action set_iso_sec_fraction {
|
102
|
+
t_iso_sec_fraction_end = p;
|
103
|
+
iso_state |= RHRR_ISO_SEC_FRACTION_SET;
|
104
|
+
}
|
98
105
|
action set_iso_zone {
|
99
106
|
t_iso_zone_end = p;
|
100
107
|
iso_state |= RHRR_ISO_ZONE_SET;
|
@@ -107,10 +114,13 @@ long rhrd__weekday_num(char * str) {
|
|
107
114
|
iso_hour = ([0-1] . [0-9] | '2' . [0-4]) >tag_iso_hour;
|
108
115
|
iso_minute = ([0-5] . [0-9]) >tag_iso_minute;
|
109
116
|
iso_second = ([0-5] . [0-9]) >tag_iso_second;
|
110
|
-
|
117
|
+
iso_sec_fraction = ('.' . digit{1,9}) >tag_iso_sec_fraction;
|
118
|
+
iso_zone = ([+\-] . digit{2} . ':'? . digit{2}?) > tag_iso_zone;
|
111
119
|
|
112
120
|
iso_date = (iso_year . [\-/] . iso_month . [\-/] . iso_day);
|
113
|
-
iso_time = (iso_hour . ':' . iso_minute . ':' . iso_second .
|
121
|
+
iso_time = (iso_hour . ':' . iso_minute . ':' . iso_second .
|
122
|
+
(iso_sec_fraction %set_iso_sec_fraction)? .
|
123
|
+
(iso_zone %set_iso_zone)? ) %set_iso_time;
|
114
124
|
iso_date_time = (iso_date . ([Tt ] . iso_time)? . space*) %/set_parser_iso;
|
115
125
|
|
116
126
|
# RFC 2822 / HTTP
|
@@ -197,6 +207,7 @@ VALUE rhrd__ragel_parse(char * p, long len) {
|
|
197
207
|
long hour = 0;
|
198
208
|
long minute = 0;
|
199
209
|
long second = 0;
|
210
|
+
double sec_fraction = 0;
|
200
211
|
|
201
212
|
VALUE rzone;
|
202
213
|
char * zone = NULL;
|
@@ -210,6 +221,8 @@ VALUE rhrd__ragel_parse(char * p, long len) {
|
|
210
221
|
char * t_iso_hour= NULL;
|
211
222
|
char * t_iso_minute = NULL;
|
212
223
|
char * t_iso_second = NULL;
|
224
|
+
char * t_iso_sec_fraction = NULL;
|
225
|
+
char * t_iso_sec_fraction_end = NULL;
|
213
226
|
char * t_iso_zone = NULL;
|
214
227
|
char * t_iso_zone_end = NULL;
|
215
228
|
|
@@ -254,10 +267,22 @@ VALUE rhrd__ragel_parse(char * p, long len) {
|
|
254
267
|
minute = atol(t_iso_minute);
|
255
268
|
second = atol(t_iso_second);
|
256
269
|
state |= RHRR_HOUR_SET | RHRR_MINUTE_SET | RHRR_SECOND_SET;
|
270
|
+
if (iso_state & RHRR_ISO_SEC_FRACTION_SET) {
|
271
|
+
sec_fraction = atoi(t_iso_sec_fraction+1) / pow(10, t_iso_sec_fraction_end - t_iso_sec_fraction - 1);
|
272
|
+
state |= RHRR_SEC_FRACTION_SET;
|
273
|
+
}
|
257
274
|
if (iso_state & RHRR_ISO_ZONE_SET) {
|
258
275
|
zone = t_iso_zone;
|
259
276
|
zone_len = t_iso_zone_end - zone;
|
260
|
-
|
277
|
+
if (zone_len == 3) { /* case for postgresql +03 */
|
278
|
+
offset = atol(zone) * 3600;
|
279
|
+
} else if (zone_len == 6) { /* standart iso */
|
280
|
+
offset = atol(zone) * 3600 + atol(zone + 4) * 60;
|
281
|
+
} else if (zone_len == 5) { /* case for sqlite +0300 */
|
282
|
+
char hours[3] = { zone[1], zone[2], 0};
|
283
|
+
offset = atol(hours) * 3600 + atol(zone + 3) * 60;
|
284
|
+
offset *= (zone[0] == '-') ? -1 : 1;
|
285
|
+
}
|
261
286
|
state |= RHRR_ZONE_SET | RHRR_OFFSET_SET;
|
262
287
|
}
|
263
288
|
}
|
@@ -339,6 +364,9 @@ VALUE rhrd__ragel_parse(char * p, long len) {
|
|
339
364
|
if(state & RHRR_SECOND_SET) {
|
340
365
|
rb_hash_aset(hash, rhrd_sym_sec, LONG2NUM(second));
|
341
366
|
}
|
367
|
+
if(state & RHRR_SEC_FRACTION_SET) {
|
368
|
+
rb_hash_aset(hash, rhrd_sym_sec_fraction, rb_float_new(sec_fraction));
|
369
|
+
}
|
342
370
|
if(state & RHRR_ZONE_SET) {
|
343
371
|
rzone = rb_str_new(zone, zone_len);
|
344
372
|
rb_hash_aset(hash, rhrd_sym_zone, rzone);
|
data/lib/1.8/date_ext.so
CHANGED
Binary file
|
data/lib/1.9/date_ext.so
CHANGED
Binary file
|
data/spec/datetime/parse_spec.rb
CHANGED
@@ -8,6 +8,21 @@ describe "DateTime._parse" do
|
|
8
8
|
it "should have :sec_fraction entry be the fraction of second" do
|
9
9
|
DateTime._parse('12:13:15.678900')[:sec_fraction].should be_close(0.6789, 0.0000000000001)
|
10
10
|
end
|
11
|
+
|
12
|
+
it "should parse zone format returned by postgresql" do
|
13
|
+
DateTime._parse('2001-01-01 01:01:01+03').should == {:year=>2001, :mon=>1, :mday=>1, :hour=>1, :min=>1, :sec=>1, :zone=>'+03', :offset=>10800}
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should parse microseconds and zone by postgresql format" do
|
17
|
+
hash = DateTime._parse('2001-01-01 01:01:01.00001-03')
|
18
|
+
hash[:sec_fraction].should be_close(0.00001, 1e-14)
|
19
|
+
hash[:zone].should == '-03'
|
20
|
+
hash[:offset].should == -10800
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should parse zone format as returned by sqlite3" do
|
24
|
+
DateTime._parse('2001-01-01 01:01:01+0300').should == {:year=>2001, :mon=>1, :mday=>1, :hour=>1, :min=>1, :sec=>1, :zone=>'+0300', :offset=>10800}
|
25
|
+
end
|
11
26
|
end
|
12
27
|
|
13
28
|
describe "DateTime.parse" do
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: home_run
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 19
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 1.0.
|
9
|
+
- 2
|
10
|
+
version: 1.0.2
|
11
11
|
platform: x86-mswin32-60
|
12
12
|
authors:
|
13
13
|
- Jeremy Evans
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-03-18 00:00:00 -07:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|