2 test_description="date/time parser module"
5 # Sanity/smoke tests for the date/time parser independent of notmuch
14 ${TEST_DIRECTORY}/parse-time --format=%s "$*"
17 test_begin_subtest "date(1) default format without TZ code"
18 test_expect_equal "$(_parse_time Fri Aug 3 23:06:06 2012)" "$(_date Fri Aug 3 23:06:06 2012)"
20 test_begin_subtest "date(1) --rfc-2822 format"
21 test_expect_equal "$(_parse_time Fri, 03 Aug 2012 23:07:46 +0100)" "$(_date Fri, 03 Aug 2012 23:07:46 +0100)"
23 test_begin_subtest "date(1) --rfc=3339=seconds format"
24 test_expect_equal "$(_parse_time 2012-08-03 23:09:37+03:00)" "$(_date 2012-08-03 23:09:37+03:00)"
26 test_begin_subtest "Date parser tests"
27 REFERENCE=$(_date Tue Jan 11 11:11:00 +0000 2011)
29 now ==> Tue Jan 11 11:11:00 +0000 2011
30 2010-1-1 ==> ERROR: DATEFORMAT
31 Jan 2 ==> Sun Jan 02 11:11:00 +0000 2011
32 Mon ==> Mon Jan 10 11:11:00 +0000 2011
33 last Friday ==> ERROR: FORMAT
34 2 hours ago ==> Tue Jan 11 09:11:00 +0000 2011
35 last month ==> Sat Dec 11 11:11:00 +0000 2010
36 month ago ==> Sat Dec 11 11:11:00 +0000 2010
37 two mo ==> Thu Nov 11 11:11:00 +0000 2010
38 3M ==> Mon Oct 11 11:11:00 +0000 2010
39 4-mont ==> Sat Sep 11 11:11:00 +0000 2010
40 5m ==> Tue Jan 11 11:06:00 +0000 2011
41 dozen mi ==> Tue Jan 11 10:59:00 +0000 2011
42 8am ==> Tue Jan 11 08:00:00 +0000 2011
43 9:15 ==> Tue Jan 11 09:15:00 +0000 2011
44 12:34 ==> Tue Jan 11 12:34:00 +0000 2011
45 monday ==> Mon Jan 10 11:11:00 +0000 2011
46 yesterday ==> Mon Jan 10 11:11:00 +0000 2011
47 tomorrow ==> ERROR: KEYWORD
48 ==> Tue Jan 11 11:11:00 +0000 2011 # empty string is reference time
50 Aug 3 23:06:06 2012 ==> Fri Aug 03 23:06:06 +0000 2012 # date(1) default format without TZ code
51 Fri, 03 Aug 2012 23:07:46 +0100 ==> Fri Aug 03 22:07:46 +0000 2012 # rfc-2822
52 2012-08-03 23:09:37+03:00 ==> Fri Aug 03 20:09:37 +0000 2012 # rfc-3339 seconds
54 10s ==> Tue Jan 11 11:10:50 +0000 2011
55 19701223s ==> Fri May 28 10:37:17 +0000 2010
56 19701223 ==> Wed Dec 23 11:11:00 +0000 1970
58 19701223 +0100 ==> Wed Dec 23 11:11:00 +0000 1970 # Timezone is ignored without an error
60 today ==^^> Wed Jan 12 00:00:00 +0000 2011
61 today ==^> Tue Jan 11 23:59:59 +0000 2011
62 today ==_> Tue Jan 11 00:00:00 +0000 2011
64 this week ==^^> Sun Jan 16 00:00:00 +0000 2011
65 this week ==^> Sat Jan 15 23:59:59 +0000 2011
66 this week ==_> Sun Jan 09 00:00:00 +0000 2011
68 two months ago ==> Thu Nov 11 11:11:00 +0000 2010
69 two months ==> Thu Nov 11 11:11:00 +0000 2010
71 @1348569850 ==> Tue Sep 25 10:44:10 +0000 2012
72 @10 ==> Thu Jan 01 00:00:10 +0000 1970
75 ${TEST_DIRECTORY}/parse-time --ref=${REFERENCE} < INPUT > OUTPUT
76 test_expect_equal_file INPUT OUTPUT