4 class TestRepeaterFortnight < Test::Unit::TestCase
7 @now = Time.local(2006, 8, 16, 14, 0, 0, 0)
11 fortnights = Chronic::RepeaterFortnight.new(:fortnight)
12 fortnights.start = @now
14 next_fortnight = fortnights.next(:future)
15 assert_equal Time.local(2006, 8, 20), next_fortnight.begin
16 assert_equal Time.local(2006, 9, 3), next_fortnight.end
18 next_next_fortnight = fortnights.next(:future)
19 assert_equal Time.local(2006, 9, 3), next_next_fortnight.begin
20 assert_equal Time.local(2006, 9, 17), next_next_fortnight.end
24 fortnights = Chronic::RepeaterFortnight.new(:fortnight)
25 fortnights.start = @now
27 last_fortnight = fortnights.next(:past)
28 assert_equal Time.local(2006, 7, 30), last_fortnight.begin
29 assert_equal Time.local(2006, 8, 13), last_fortnight.end
31 last_last_fortnight = fortnights.next(:past)
32 assert_equal Time.local(2006, 7, 16), last_last_fortnight.begin
33 assert_equal Time.local(2006, 7, 30), last_last_fortnight.end
37 fortnights = Chronic::RepeaterFortnight.new(:fortnight)
38 fortnights.start = @now
40 this_fortnight = fortnights.this(:future)
41 assert_equal Time.local(2006, 8, 16, 15), this_fortnight.begin
42 assert_equal Time.local(2006, 8, 27), this_fortnight.end
46 fortnights = Chronic::RepeaterFortnight.new(:fortnight)
47 fortnights.start = @now
49 this_fortnight = fortnights.this(:past)
50 assert_equal Time.local(2006, 8, 13, 0), this_fortnight.begin
51 assert_equal Time.local(2006, 8, 16, 14), this_fortnight.end
55 span = Chronic::Span.new(@now, @now + 1)
57 offset_span = Chronic::RepeaterWeek.new(:week).offset(span, 3, :future)
59 assert_equal Time.local(2006, 9, 6, 14), offset_span.begin
60 assert_equal Time.local(2006, 9, 6, 14, 0, 1), offset_span.end