chronic 0.6.6 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +1 -0
- data/HISTORY.md +15 -0
- data/README.md +5 -0
- data/chronic.gemspec +3 -0
- data/lib/chronic/chronic.rb +73 -62
- data/lib/chronic/grabber.rb +9 -7
- data/lib/chronic/handler.rb +10 -12
- data/lib/chronic/handlers.rb +66 -3
- data/lib/chronic/ordinal.rb +12 -9
- data/lib/chronic/pointer.rb +9 -7
- data/lib/chronic/repeater.rb +28 -18
- data/lib/chronic/repeaters/repeater_day_portion.rb +25 -11
- data/lib/chronic/scalar.rb +30 -23
- data/lib/chronic/season.rb +1 -12
- data/lib/chronic/separator.rb +21 -15
- data/lib/chronic/tag.rb +5 -11
- data/lib/chronic/time_zone.rb +9 -7
- data/lib/chronic/token.rb +12 -10
- data/lib/chronic.rb +49 -43
- data/test/helper.rb +7 -1
- data/test/{test_Chronic.rb → test_chronic.rb} +6 -6
- data/test/{test_DaylightSavings.rb → test_daylight_savings.rb} +1 -1
- data/test/{test_Handler.rb → test_handler.rb} +1 -1
- data/test/{test_MiniDate.rb → test_mini_date.rb} +9 -9
- data/test/{test_Numerizer.rb → test_numerizer.rb} +1 -1
- data/test/test_parsing.rb +94 -10
- data/test/{test_RepeaterDayName.rb → test_repeater_day_name.rb} +1 -1
- data/test/test_repeater_day_portion.rb +254 -0
- data/test/{test_RepeaterFortnight.rb → test_repeater_fortnight.rb} +1 -1
- data/test/{test_RepeaterHour.rb → test_repeater_hour.rb} +1 -1
- data/test/{test_RepeaterMinute.rb → test_repeater_minute.rb} +1 -1
- data/test/{test_RepeaterMonth.rb → test_repeater_month.rb} +1 -1
- data/test/{test_RepeaterMonthName.rb → test_repeater_month_name.rb} +1 -1
- data/test/{test_RepeaterSeason.rb → test_repeater_season.rb} +1 -1
- data/test/{test_RepeaterTime.rb → test_repeater_time.rb} +1 -1
- data/test/{test_RepeaterWeek.rb → test_repeater_week.rb} +1 -1
- data/test/{test_RepeaterWeekday.rb → test_repeater_weekday.rb} +1 -1
- data/test/{test_RepeaterWeekend.rb → test_repeater_weekend.rb} +1 -1
- data/test/{test_RepeaterYear.rb → test_repeater_year.rb} +1 -1
- data/test/{test_Span.rb → test_span.rb} +1 -1
- data/test/{test_Token.rb → test_token.rb} +1 -1
- metadata +76 -44
- data/.gemtest +0 -0
- data/.yardopts +0 -3
data/test/test_parsing.rb
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
require 'helper'
|
|
2
2
|
|
|
3
|
-
class TestParsing <
|
|
3
|
+
class TestParsing < TestCase
|
|
4
4
|
# Wed Aug 16 14:00:00 UTC 2006
|
|
5
5
|
TIME_2006_08_16_14_00_00 = Time.local(2006, 8, 16, 14, 0, 0, 0)
|
|
6
6
|
|
|
@@ -252,6 +252,9 @@ class TestParsing < Test::Unit::TestCase
|
|
|
252
252
|
|
|
253
253
|
time = parse_now("27/5/1979 @ 0700")
|
|
254
254
|
assert_equal Time.local(1979, 5, 27, 7), time
|
|
255
|
+
|
|
256
|
+
time = parse_now("03/18/2012 09:26 pm")
|
|
257
|
+
assert_equal Time.local(2012, 3, 18, 21, 26), time
|
|
255
258
|
end
|
|
256
259
|
|
|
257
260
|
def test_handle_sy_sm_sd
|
|
@@ -278,19 +281,34 @@ class TestParsing < Test::Unit::TestCase
|
|
|
278
281
|
|
|
279
282
|
time = parse_now("1902-08-20")
|
|
280
283
|
assert_equal Time.local(1902, 8, 20, 12, 0, 0), time
|
|
284
|
+
|
|
285
|
+
# exif date time original
|
|
286
|
+
time = parse_now("2012:05:25 22:06:50")
|
|
287
|
+
assert_equal Time.local(2012, 5, 25, 22, 6, 50), time
|
|
281
288
|
end
|
|
282
289
|
|
|
283
|
-
def
|
|
290
|
+
def test_handle_sm_sd
|
|
284
291
|
time = parse_now("05/06")
|
|
285
|
-
assert_equal Time.local(2006, 5,
|
|
292
|
+
assert_equal Time.local(2006, 5, 6, 12), time
|
|
286
293
|
|
|
287
|
-
time = parse_now("
|
|
288
|
-
assert_equal Time.local(2006,
|
|
294
|
+
time = parse_now("05/06", :endian_precedence => [:little, :medium])
|
|
295
|
+
assert_equal Time.local(2006, 6, 5, 12), time
|
|
289
296
|
|
|
290
|
-
time = parse_now("13/
|
|
291
|
-
|
|
297
|
+
time = parse_now("13/01")
|
|
298
|
+
assert_nil time
|
|
292
299
|
end
|
|
293
300
|
|
|
301
|
+
# def test_handle_sm_sy
|
|
302
|
+
# time = parse_now("05/06")
|
|
303
|
+
# assert_equal Time.local(2006, 5, 16, 12), time
|
|
304
|
+
#
|
|
305
|
+
# time = parse_now("12/06")
|
|
306
|
+
# assert_equal Time.local(2006, 12, 16, 12), time
|
|
307
|
+
#
|
|
308
|
+
# time = parse_now("13/06")
|
|
309
|
+
# assert_equal nil, time
|
|
310
|
+
# end
|
|
311
|
+
|
|
294
312
|
def test_handle_r
|
|
295
313
|
end
|
|
296
314
|
|
|
@@ -354,6 +372,11 @@ class TestParsing < Test::Unit::TestCase
|
|
|
354
372
|
assert_equal Time.local(2006, 8, 9, 12), time
|
|
355
373
|
end
|
|
356
374
|
|
|
375
|
+
def test_handle_sm_rmn_sy
|
|
376
|
+
time = parse_now('30-Mar-11')
|
|
377
|
+
assert_equal Time.local(2011, 3, 30, 12), time
|
|
378
|
+
end
|
|
379
|
+
|
|
357
380
|
# end of testing handlers
|
|
358
381
|
|
|
359
382
|
def test_parse_guess_r
|
|
@@ -575,13 +598,33 @@ class TestParsing < Test::Unit::TestCase
|
|
|
575
598
|
time = parse_now("tonight")
|
|
576
599
|
assert_equal Time.local(2006, 8, 16, 22), time
|
|
577
600
|
|
|
601
|
+
# hour
|
|
602
|
+
|
|
603
|
+
time = parse_now("next hr")
|
|
604
|
+
assert_equal Time.local(2006, 8, 16, 15, 30, 0), time
|
|
605
|
+
|
|
606
|
+
time = parse_now("next hrs")
|
|
607
|
+
assert_equal Time.local(2006, 8, 16, 15, 30, 0), time
|
|
608
|
+
|
|
578
609
|
# minute
|
|
579
610
|
|
|
611
|
+
time = parse_now("next min")
|
|
612
|
+
assert_equal Time.local(2006, 8, 16, 14, 1, 30), time
|
|
613
|
+
|
|
614
|
+
time = parse_now("next mins")
|
|
615
|
+
assert_equal Time.local(2006, 8, 16, 14, 1, 30), time
|
|
616
|
+
|
|
580
617
|
time = parse_now("next minute")
|
|
581
618
|
assert_equal Time.local(2006, 8, 16, 14, 1, 30), time
|
|
582
619
|
|
|
583
620
|
# second
|
|
584
621
|
|
|
622
|
+
time = parse_now("next sec")
|
|
623
|
+
assert_equal Time.local(2006, 8, 16, 14, 0, 1), time
|
|
624
|
+
|
|
625
|
+
time = parse_now("next secs")
|
|
626
|
+
assert_equal Time.local(2006, 8, 16, 14, 0, 1), time
|
|
627
|
+
|
|
585
628
|
time = parse_now("this second")
|
|
586
629
|
assert_equal Time.local(2006, 8, 16, 14), time
|
|
587
630
|
|
|
@@ -674,6 +717,20 @@ class TestParsing < Test::Unit::TestCase
|
|
|
674
717
|
assert_equal Time.local(2006, 8, 8, 12), time
|
|
675
718
|
end
|
|
676
719
|
|
|
720
|
+
def test_parse_guess_a_ago
|
|
721
|
+
time = parse_now("AN hour ago")
|
|
722
|
+
assert_equal Time.local(2006, 8, 16, 13), time
|
|
723
|
+
|
|
724
|
+
time = parse_now("A day ago")
|
|
725
|
+
assert_equal Time.local(2006, 8, 15, 14), time
|
|
726
|
+
|
|
727
|
+
time = parse_now("a month ago")
|
|
728
|
+
assert_equal Time.local(2006, 7, 16, 14), time
|
|
729
|
+
|
|
730
|
+
time = parse_now("a year ago")
|
|
731
|
+
assert_equal Time.local(2005, 8, 16, 14), time
|
|
732
|
+
end
|
|
733
|
+
|
|
677
734
|
def test_parse_guess_s_r_p
|
|
678
735
|
# past
|
|
679
736
|
|
|
@@ -836,6 +893,7 @@ class TestParsing < Test::Unit::TestCase
|
|
|
836
893
|
assert_equal parse_now("33 days from now"), parse_now("thirty-three days from now")
|
|
837
894
|
assert_equal parse_now("2867532 seconds from now"), parse_now("two million eight hundred and sixty seven thousand five hundred and thirty two seconds from now")
|
|
838
895
|
assert_equal parse_now("may 10th"), parse_now("may tenth")
|
|
896
|
+
assert_equal parse_now("second monday in january"), parse_now("2nd monday in january")
|
|
839
897
|
end
|
|
840
898
|
|
|
841
899
|
def test_parse_only_complete_pointers
|
|
@@ -855,11 +913,11 @@ class TestParsing < Test::Unit::TestCase
|
|
|
855
913
|
end
|
|
856
914
|
|
|
857
915
|
def test_argument_validation
|
|
858
|
-
|
|
916
|
+
assert_raises(ArgumentError) do
|
|
859
917
|
time = Chronic.parse("may 27", :foo => :bar)
|
|
860
918
|
end
|
|
861
919
|
|
|
862
|
-
|
|
920
|
+
assert_raises(ArgumentError) do
|
|
863
921
|
time = Chronic.parse("may 27", :context => :bar)
|
|
864
922
|
end
|
|
865
923
|
end
|
|
@@ -915,7 +973,7 @@ class TestParsing < Test::Unit::TestCase
|
|
|
915
973
|
t1 = Chronic.parse("now")
|
|
916
974
|
sleep 0.1
|
|
917
975
|
t2 = Chronic.parse("now")
|
|
918
|
-
|
|
976
|
+
refute_equal t1, t2
|
|
919
977
|
end
|
|
920
978
|
|
|
921
979
|
def test_noon
|
|
@@ -926,11 +984,37 @@ class TestParsing < Test::Unit::TestCase
|
|
|
926
984
|
def test_handle_rdn_rmn_sd
|
|
927
985
|
time = parse_now("Thu Aug 10")
|
|
928
986
|
assert_equal Time.local(2006, 8, 10, 12), time
|
|
987
|
+
|
|
988
|
+
time = parse_now("Thursday July 31")
|
|
989
|
+
assert_equal Time.local(2006, 7, 31, 12), time
|
|
990
|
+
|
|
991
|
+
time = parse_now("Thursday December 31")
|
|
992
|
+
assert_equal Time.local(2006, 12, 31, 12), time
|
|
993
|
+
end
|
|
994
|
+
|
|
995
|
+
def test_handle_rdn_rmn_sd_sy
|
|
996
|
+
time = parse_now("Thu Aug 10 2006")
|
|
997
|
+
assert_equal Time.local(2006, 8, 10, 12), time
|
|
998
|
+
|
|
999
|
+
time = parse_now("Thursday July 31 2006")
|
|
1000
|
+
assert_equal Time.local(2006, 7, 31, 12), time
|
|
1001
|
+
|
|
1002
|
+
time = parse_now("Thursday December 31 2006")
|
|
1003
|
+
assert_equal Time.local(2006, 12, 31, 12), time
|
|
1004
|
+
|
|
1005
|
+
time = parse_now("Thursday December 30 2006")
|
|
1006
|
+
assert_equal Time.local(2006, 12, 30, 12), time
|
|
929
1007
|
end
|
|
930
1008
|
|
|
931
1009
|
def test_handle_rdn_rmn_od
|
|
932
1010
|
time = parse_now("Thu Aug 10th")
|
|
933
1011
|
assert_equal Time.local(2006, 8, 10, 12), time
|
|
1012
|
+
|
|
1013
|
+
time = parse_now("Thursday July 31st")
|
|
1014
|
+
assert_equal Time.local(2006, 7, 31, 12), time
|
|
1015
|
+
|
|
1016
|
+
time = parse_now("Thursday December 31st")
|
|
1017
|
+
assert_equal Time.local(2006, 12, 31, 12), time
|
|
934
1018
|
end
|
|
935
1019
|
|
|
936
1020
|
private
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
require 'helper'
|
|
2
|
+
|
|
3
|
+
class TestRepeaterDayPortion < TestCase
|
|
4
|
+
|
|
5
|
+
def setup
|
|
6
|
+
@now = Time.local(2006, 8, 16, 14, 0, 0, 0)
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def test_am_future
|
|
10
|
+
day_portion = Chronic::RepeaterDayPortion.new(:am)
|
|
11
|
+
day_portion.start = @now
|
|
12
|
+
|
|
13
|
+
next_time = day_portion.next(:future)
|
|
14
|
+
assert_equal Time.local(2006, 8, 17, 00), next_time.begin
|
|
15
|
+
assert_equal Time.local(2006, 8, 17, 11, 59, 59), next_time.end
|
|
16
|
+
|
|
17
|
+
next_next_time = day_portion.next(:future)
|
|
18
|
+
assert_equal Time.local(2006, 8, 18, 00), next_next_time.begin
|
|
19
|
+
assert_equal Time.local(2006, 8, 18, 11, 59, 59), next_next_time.end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def test_am_past
|
|
23
|
+
day_portion = Chronic::RepeaterDayPortion.new(:am)
|
|
24
|
+
day_portion.start = @now
|
|
25
|
+
|
|
26
|
+
next_time = day_portion.next(:past)
|
|
27
|
+
assert_equal Time.local(2006, 8, 16, 00), next_time.begin
|
|
28
|
+
assert_equal Time.local(2006, 8, 16, 11, 59, 59), next_time.end
|
|
29
|
+
|
|
30
|
+
next_next_time = day_portion.next(:past)
|
|
31
|
+
assert_equal Time.local(2006, 8, 15, 00), next_next_time.begin
|
|
32
|
+
assert_equal Time.local(2006, 8, 15, 11, 59, 59), next_next_time.end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def test_am_future_with_daylight_savings_time_boundary
|
|
36
|
+
@now = Time.local(2012,11,3,0,0,0)
|
|
37
|
+
day_portion = Chronic::RepeaterDayPortion.new(:am)
|
|
38
|
+
day_portion.start = @now
|
|
39
|
+
|
|
40
|
+
next_time = day_portion.next(:future)
|
|
41
|
+
assert_equal Time.local(2012, 11, 4, 00), next_time.begin
|
|
42
|
+
assert_equal Time.local(2012, 11, 4, 11, 59, 59), next_time.end
|
|
43
|
+
|
|
44
|
+
next_next_time = day_portion.next(:future)
|
|
45
|
+
|
|
46
|
+
assert_equal Time.local(2012, 11, 5, 00), next_next_time.begin
|
|
47
|
+
assert_equal Time.local(2012, 11, 5, 11, 59, 59), next_next_time.end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def test_pm_future
|
|
51
|
+
day_portion = Chronic::RepeaterDayPortion.new(:pm)
|
|
52
|
+
day_portion.start = @now
|
|
53
|
+
|
|
54
|
+
next_time = day_portion.next(:future)
|
|
55
|
+
assert_equal Time.local(2006, 8, 17, 12), next_time.begin
|
|
56
|
+
assert_equal Time.local(2006, 8, 17, 23, 59, 59), next_time.end
|
|
57
|
+
|
|
58
|
+
next_next_time = day_portion.next(:future)
|
|
59
|
+
assert_equal Time.local(2006, 8, 18, 12), next_next_time.begin
|
|
60
|
+
assert_equal Time.local(2006, 8, 18, 23, 59, 59), next_next_time.end
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def test_pm_past
|
|
64
|
+
day_portion = Chronic::RepeaterDayPortion.new(:pm)
|
|
65
|
+
day_portion.start = @now
|
|
66
|
+
|
|
67
|
+
next_time = day_portion.next(:past)
|
|
68
|
+
assert_equal Time.local(2006, 8, 15, 12), next_time.begin
|
|
69
|
+
assert_equal Time.local(2006, 8, 15, 23, 59, 59), next_time.end
|
|
70
|
+
|
|
71
|
+
next_next_time = day_portion.next(:past)
|
|
72
|
+
assert_equal Time.local(2006, 8, 14, 12), next_next_time.begin
|
|
73
|
+
assert_equal Time.local(2006, 8, 14, 23, 59, 59), next_next_time.end
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def test_pm_future_with_daylight_savings_time_boundary
|
|
77
|
+
@now = Time.local(2012,11,3,0,0,0)
|
|
78
|
+
day_portion = Chronic::RepeaterDayPortion.new(:pm)
|
|
79
|
+
day_portion.start = @now
|
|
80
|
+
|
|
81
|
+
next_time = day_portion.next(:future)
|
|
82
|
+
assert_equal Time.local(2012, 11, 3, 12), next_time.begin
|
|
83
|
+
assert_equal Time.local(2012, 11, 3, 23, 59, 59), next_time.end
|
|
84
|
+
|
|
85
|
+
next_next_time = day_portion.next(:future)
|
|
86
|
+
|
|
87
|
+
assert_equal Time.local(2012, 11, 4, 12), next_next_time.begin
|
|
88
|
+
assert_equal Time.local(2012, 11, 4, 23, 59, 59), next_next_time.end
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
def test_morning_future
|
|
92
|
+
day_portion = Chronic::RepeaterDayPortion.new(:morning)
|
|
93
|
+
day_portion.start = @now
|
|
94
|
+
|
|
95
|
+
next_time = day_portion.next(:future)
|
|
96
|
+
assert_equal Time.local(2006, 8, 17, 6), next_time.begin
|
|
97
|
+
assert_equal Time.local(2006, 8, 17, 12), next_time.end
|
|
98
|
+
|
|
99
|
+
next_next_time = day_portion.next(:future)
|
|
100
|
+
assert_equal Time.local(2006, 8, 18, 6), next_next_time.begin
|
|
101
|
+
assert_equal Time.local(2006, 8, 18, 12), next_next_time.end
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
def test_morning_past
|
|
105
|
+
day_portion = Chronic::RepeaterDayPortion.new(:morning)
|
|
106
|
+
day_portion.start = @now
|
|
107
|
+
|
|
108
|
+
next_time = day_portion.next(:past)
|
|
109
|
+
assert_equal Time.local(2006, 8, 16, 6), next_time.begin
|
|
110
|
+
assert_equal Time.local(2006, 8, 16, 12), next_time.end
|
|
111
|
+
|
|
112
|
+
next_next_time = day_portion.next(:past)
|
|
113
|
+
assert_equal Time.local(2006, 8, 15, 6), next_next_time.begin
|
|
114
|
+
assert_equal Time.local(2006, 8, 15, 12), next_next_time.end
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
def test_morning_future_with_daylight_savings_time_boundary
|
|
118
|
+
@now = Time.local(2012,11,3,0,0,0)
|
|
119
|
+
day_portion = Chronic::RepeaterDayPortion.new(:morning)
|
|
120
|
+
day_portion.start = @now
|
|
121
|
+
|
|
122
|
+
next_time = day_portion.next(:future)
|
|
123
|
+
assert_equal Time.local(2012, 11, 3, 6), next_time.begin
|
|
124
|
+
assert_equal Time.local(2012, 11, 3, 12), next_time.end
|
|
125
|
+
|
|
126
|
+
next_next_time = day_portion.next(:future)
|
|
127
|
+
|
|
128
|
+
assert_equal Time.local(2012, 11, 4, 6), next_next_time.begin
|
|
129
|
+
assert_equal Time.local(2012, 11, 4, 12), next_next_time.end
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
def test_afternoon_future
|
|
133
|
+
day_portion = Chronic::RepeaterDayPortion.new(:afternoon)
|
|
134
|
+
day_portion.start = @now
|
|
135
|
+
|
|
136
|
+
next_time = day_portion.next(:future)
|
|
137
|
+
assert_equal Time.local(2006, 8, 17, 13), next_time.begin
|
|
138
|
+
assert_equal Time.local(2006, 8, 17, 17), next_time.end
|
|
139
|
+
|
|
140
|
+
next_next_time = day_portion.next(:future)
|
|
141
|
+
assert_equal Time.local(2006, 8, 18, 13), next_next_time.begin
|
|
142
|
+
assert_equal Time.local(2006, 8, 18, 17), next_next_time.end
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
def test_afternoon_past
|
|
146
|
+
day_portion = Chronic::RepeaterDayPortion.new(:afternoon)
|
|
147
|
+
day_portion.start = @now
|
|
148
|
+
|
|
149
|
+
next_time = day_portion.next(:past)
|
|
150
|
+
assert_equal Time.local(2006, 8, 15, 13), next_time.begin
|
|
151
|
+
assert_equal Time.local(2006, 8, 15, 17), next_time.end
|
|
152
|
+
|
|
153
|
+
next_next_time = day_portion.next(:past)
|
|
154
|
+
assert_equal Time.local(2006, 8, 14, 13), next_next_time.begin
|
|
155
|
+
assert_equal Time.local(2006, 8, 14, 17), next_next_time.end
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
def test_afternoon_future_with_daylight_savings_time_boundary
|
|
159
|
+
@now = Time.local(2012,11,3,0,0,0)
|
|
160
|
+
day_portion = Chronic::RepeaterDayPortion.new(:afternoon)
|
|
161
|
+
day_portion.start = @now
|
|
162
|
+
|
|
163
|
+
next_time = day_portion.next(:future)
|
|
164
|
+
assert_equal Time.local(2012, 11, 3, 13), next_time.begin
|
|
165
|
+
assert_equal Time.local(2012, 11, 3, 17), next_time.end
|
|
166
|
+
|
|
167
|
+
next_next_time = day_portion.next(:future)
|
|
168
|
+
|
|
169
|
+
assert_equal Time.local(2012, 11, 4, 13), next_next_time.begin
|
|
170
|
+
assert_equal Time.local(2012, 11, 4, 17), next_next_time.end
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
def test_evening_future
|
|
174
|
+
day_portion = Chronic::RepeaterDayPortion.new(:evening)
|
|
175
|
+
day_portion.start = @now
|
|
176
|
+
|
|
177
|
+
next_time = day_portion.next(:future)
|
|
178
|
+
assert_equal Time.local(2006, 8, 16, 17), next_time.begin
|
|
179
|
+
assert_equal Time.local(2006, 8, 16, 20), next_time.end
|
|
180
|
+
|
|
181
|
+
next_next_time = day_portion.next(:future)
|
|
182
|
+
assert_equal Time.local(2006, 8, 17, 17), next_next_time.begin
|
|
183
|
+
assert_equal Time.local(2006, 8, 17, 20), next_next_time.end
|
|
184
|
+
end
|
|
185
|
+
|
|
186
|
+
def test_evening_past
|
|
187
|
+
day_portion = Chronic::RepeaterDayPortion.new(:evening)
|
|
188
|
+
day_portion.start = @now
|
|
189
|
+
|
|
190
|
+
next_time = day_portion.next(:past)
|
|
191
|
+
assert_equal Time.local(2006, 8, 15, 17), next_time.begin
|
|
192
|
+
assert_equal Time.local(2006, 8, 15, 20), next_time.end
|
|
193
|
+
|
|
194
|
+
next_next_time = day_portion.next(:past)
|
|
195
|
+
assert_equal Time.local(2006, 8, 14, 17), next_next_time.begin
|
|
196
|
+
assert_equal Time.local(2006, 8, 14, 20), next_next_time.end
|
|
197
|
+
end
|
|
198
|
+
|
|
199
|
+
def test_evening_future_with_daylight_savings_time_boundary
|
|
200
|
+
@now = Time.local(2012,11,3,0,0,0)
|
|
201
|
+
day_portion = Chronic::RepeaterDayPortion.new(:evening)
|
|
202
|
+
day_portion.start = @now
|
|
203
|
+
|
|
204
|
+
next_time = day_portion.next(:future)
|
|
205
|
+
assert_equal Time.local(2012, 11, 3, 17), next_time.begin
|
|
206
|
+
assert_equal Time.local(2012, 11, 3, 20), next_time.end
|
|
207
|
+
|
|
208
|
+
next_next_time = day_portion.next(:future)
|
|
209
|
+
|
|
210
|
+
assert_equal Time.local(2012, 11, 4, 17), next_next_time.begin
|
|
211
|
+
assert_equal Time.local(2012, 11, 4, 20), next_next_time.end
|
|
212
|
+
end
|
|
213
|
+
|
|
214
|
+
def test_night_future
|
|
215
|
+
day_portion = Chronic::RepeaterDayPortion.new(:night)
|
|
216
|
+
day_portion.start = @now
|
|
217
|
+
|
|
218
|
+
next_time = day_portion.next(:future)
|
|
219
|
+
assert_equal Time.local(2006, 8, 16, 20), next_time.begin
|
|
220
|
+
assert_equal Time.local(2006, 8, 17, 0), next_time.end
|
|
221
|
+
|
|
222
|
+
next_next_time = day_portion.next(:future)
|
|
223
|
+
assert_equal Time.local(2006, 8, 17, 20), next_next_time.begin
|
|
224
|
+
assert_equal Time.local(2006, 8, 18, 0), next_next_time.end
|
|
225
|
+
end
|
|
226
|
+
|
|
227
|
+
def test_night_past
|
|
228
|
+
day_portion = Chronic::RepeaterDayPortion.new(:night)
|
|
229
|
+
day_portion.start = @now
|
|
230
|
+
|
|
231
|
+
next_time = day_portion.next(:past)
|
|
232
|
+
assert_equal Time.local(2006, 8, 15, 20), next_time.begin
|
|
233
|
+
assert_equal Time.local(2006, 8, 16, 0), next_time.end
|
|
234
|
+
|
|
235
|
+
next_next_time = day_portion.next(:past)
|
|
236
|
+
assert_equal Time.local(2006, 8, 14, 20), next_next_time.begin
|
|
237
|
+
assert_equal Time.local(2006, 8, 15, 0), next_next_time.end
|
|
238
|
+
end
|
|
239
|
+
|
|
240
|
+
def test_night_future_with_daylight_savings_time_boundary
|
|
241
|
+
@now = Time.local(2012,11,3,0,0,0)
|
|
242
|
+
day_portion = Chronic::RepeaterDayPortion.new(:night)
|
|
243
|
+
day_portion.start = @now
|
|
244
|
+
|
|
245
|
+
next_time = day_portion.next(:future)
|
|
246
|
+
assert_equal Time.local(2012, 11, 3, 20), next_time.begin
|
|
247
|
+
assert_equal Time.local(2012, 11, 4, 0), next_time.end
|
|
248
|
+
|
|
249
|
+
next_next_time = day_portion.next(:future)
|
|
250
|
+
|
|
251
|
+
assert_equal Time.local(2012, 11, 4, 20), next_next_time.begin
|
|
252
|
+
assert_equal Time.local(2012, 11, 5, 0), next_next_time.end
|
|
253
|
+
end
|
|
254
|
+
end
|