Skip to content

Commit cd741d1

Browse files
committed
Add more commonly used formats and remove formats that don't work
1 parent 20ccfb3 commit cd741d1

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
lines changed

src/converter.rs

+22-22
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,13 @@ pub struct Converter {
1919
// They get converted into Regexes and are validated
2020
const DEFAULT_FORMATS: &[&str] = &[
2121
"%Y-%m-%dT%H:%M:%S%z", // 2014-11-28T12:00:09+0000
22-
"%d/%b/%Y:%H:%M:%S %z", // 04/Nov/2018:12:13:49 +0000
23-
"%d/%b/%Y:%H:%M:%S %:z", // 04/Nov/2018:12:13:49 +00:00
22+
"%Y-%m-%d %H:%M:%S%z", // 2014-11-28 12:00:09+0000
23+
"%Y-%m-%dT%H:%M:%S %z", // 2014-11-28T12:00:09 +0000
24+
"%Y-%m-%d %H:%M:%S %z", // 2014-11-28 12:00:09 +0000
25+
"%d/%b/%Y:%H:%M:%S %z", // 04/Nov/2018:12:13:49 +0000 Nginx
26+
"%d/%b/%Y:%H:%M:%S%.3f %z", // 04/Nov/2018:12:13:49.334 +0000 Nginx
27+
"%d/%b/%Y:%H:%M:%S", // 04/Nov/2018:12:13:49 HAProxy
2428
"%a, %d %b %Y %H:%M:%S %z", // Fri, 28 Nov 2014 12:00:09 +0000
25-
"%a, %d %b %Y %H:%M:%S %Z", // Fri, 28 Nov 2014 12:00:09 UTC
2629
"%Y-%m-%dT%H:%M:%SZ", // 2014-11-28T12:00:09Z
2730
"%Y-%m-%dT%H:%M:%S", // 2014-11-28T12:00:09
2831
"%Y-%m-%d %H:%M:%S", // 2014-11-28 12:00:09
@@ -237,31 +240,28 @@ mod converter_tests {
237240
inputs: vec![
238241
"Fri, 28 Nov 2014 12:00:09 +0000",
239242
"Thu, 27 Nov 2014 01:00:09 +0530",
240-
"Wed, 26 Nov 2014 14:00:09 +01:00",
243+
"14/Nov/2018:22:14:27 -0800",
244+
"2014-11-28T12:00:09+0500",
245+
"2014-11-28 12:00:09+0500",
246+
"2014-11-28T12:00:09 +0500",
247+
"2014-11-28 12:00:09 +0500",
248+
"04/Nov/2018:12:13:49 +0500 Nginx",
249+
"04/Nov/2018:12:13:49.334 +0500 Nginx",
250+
"04/Nov/2018:12:13:49 HAProxy",
241251
],
242252
outputs: vec![
243253
"Fri, 28 Nov 2014 13:00:09 +0100",
244254
"Wed, 26 Nov 2014 20:30:09 +0100",
245-
"Wed, 26 Nov 2014 14:00:09 +01:00",
255+
"15/Nov/2018:07:14:27 +0100",
256+
"2014-11-28T08:00:09+0100",
257+
"2014-11-28 08:00:09+0100",
258+
"2014-11-28T08:00:09 +0100",
259+
"2014-11-28 08:00:09 +0100",
260+
"04/Nov/2018:08:13:49 +0100 Nginx",
261+
"04/Nov/2018:08:13:49.334 +0100 Nginx",
262+
"04/Nov/2018:13:13:49 HAProxy",
246263
],
247264
},
248-
// Issue: https://github.com/chronotope/chrono/issues/288
249-
// TestCase {
250-
// timezone: Some("Europe/Paris"),
251-
// format: None,
252-
// inputs: vec![
253-
// "Fri, 28 Nov 2014 12:00:09 GMT",
254-
// "Thu, 27 Nov 2014 01:00:09 IST",
255-
// "Wed, 26 Nov 2014 14:00:09 CET",
256-
// ],
257-
// outputs: vec![
258-
// "Fri, 28 Nov 2014 13:00:09 CET",
259-
// "Wed, 26 Nov 2014 20:30:09 CET",
260-
// "Wed, 26 Nov 2014 14:00:09 CET",
261-
// ],
262-
// },
263-
264-
// This test can pass only if local timezone is Asia/Kolkata
265265
TestCase {
266266
timezone: None,
267267
format: None,

0 commit comments

Comments
 (0)