chronic 0.2.3 → 0.4.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.
Files changed (63) hide show
  1. data/HISTORY.md +103 -0
  2. data/LICENSE +21 -0
  3. data/Manifest.txt +16 -5
  4. data/README.md +171 -0
  5. data/Rakefile +136 -15
  6. data/benchmark/benchmark.rb +13 -0
  7. data/chronic.gemspec +82 -0
  8. data/lib/chronic/chronic.rb +65 -147
  9. data/lib/chronic/grabber.rb +13 -17
  10. data/lib/chronic/handlers.rb +216 -138
  11. data/lib/chronic/mini_date.rb +27 -0
  12. data/lib/chronic/numerizer.rb +120 -0
  13. data/lib/chronic/ordinal.rb +11 -16
  14. data/lib/chronic/pointer.rb +11 -13
  15. data/lib/chronic/repeater.rb +117 -106
  16. data/lib/chronic/repeaters/repeater_day.rb +50 -43
  17. data/lib/chronic/repeaters/repeater_day_name.rb +49 -42
  18. data/lib/chronic/repeaters/repeater_day_portion.rb +82 -80
  19. data/lib/chronic/repeaters/repeater_fortnight.rb +60 -53
  20. data/lib/chronic/repeaters/repeater_hour.rb +50 -43
  21. data/lib/chronic/repeaters/repeater_minute.rb +50 -43
  22. data/lib/chronic/repeaters/repeater_month.rb +63 -56
  23. data/lib/chronic/repeaters/repeater_month_name.rb +91 -82
  24. data/lib/chronic/repeaters/repeater_season.rb +125 -20
  25. data/lib/chronic/repeaters/repeater_season_name.rb +43 -22
  26. data/lib/chronic/repeaters/repeater_second.rb +40 -33
  27. data/lib/chronic/repeaters/repeater_time.rb +118 -106
  28. data/lib/chronic/repeaters/repeater_week.rb +64 -57
  29. data/lib/chronic/repeaters/repeater_weekday.rb +86 -0
  30. data/lib/chronic/repeaters/repeater_weekend.rb +58 -51
  31. data/lib/chronic/repeaters/repeater_year.rb +58 -50
  32. data/lib/chronic/scalar.rb +37 -27
  33. data/lib/chronic/separator.rb +34 -37
  34. data/lib/chronic/span.rb +31 -0
  35. data/lib/chronic/tag.rb +26 -0
  36. data/lib/chronic/time_zone.rb +9 -10
  37. data/lib/chronic/token.rb +35 -0
  38. data/lib/chronic.rb +34 -25
  39. data/test/helper.rb +6 -0
  40. data/test/test_Chronic.rb +22 -18
  41. data/test/test_DaylightSavings.rb +118 -0
  42. data/test/test_Handler.rb +37 -38
  43. data/test/test_Numerizer.rb +66 -42
  44. data/test/test_RepeaterDayName.rb +15 -16
  45. data/test/test_RepeaterFortnight.rb +16 -17
  46. data/test/test_RepeaterHour.rb +22 -19
  47. data/test/test_RepeaterMinute.rb +34 -0
  48. data/test/test_RepeaterMonth.rb +16 -17
  49. data/test/test_RepeaterMonthName.rb +17 -18
  50. data/test/test_RepeaterTime.rb +20 -22
  51. data/test/test_RepeaterWeek.rb +16 -17
  52. data/test/test_RepeaterWeekday.rb +55 -0
  53. data/test/test_RepeaterWeekend.rb +21 -22
  54. data/test/test_RepeaterYear.rb +17 -18
  55. data/test/test_Span.rb +5 -6
  56. data/test/test_Time.rb +11 -12
  57. data/test/test_Token.rb +5 -6
  58. data/test/test_parsing.rb +395 -208
  59. metadata +68 -52
  60. data/History.txt +0 -53
  61. data/README.txt +0 -149
  62. data/lib/numerizer/numerizer.rb +0 -103
  63. data/test/suite.rb +0 -9
@@ -1,117 +1,129 @@
1
- class Chronic::RepeaterTime < Chronic::Repeater #:nodoc:
2
- class Tick #:nodoc:
3
- attr_accessor :time
4
-
5
- def initialize(time, ambiguous = false)
6
- @time = time
7
- @ambiguous = ambiguous
8
- end
9
-
10
- def ambiguous?
11
- @ambiguous
12
- end
13
-
14
- def *(other)
15
- Tick.new(@time * other, @ambiguous)
16
- end
17
-
18
- def to_f
19
- @time.to_f
20
- end
21
-
22
- def to_s
23
- @time.to_s + (@ambiguous ? '?' : '')
1
+ module Chronic
2
+ class RepeaterTime < Repeater #:nodoc:
3
+ class Tick #:nodoc:
4
+ attr_accessor :time
5
+
6
+ def initialize(time, ambiguous = false)
7
+ @time = time
8
+ @ambiguous = ambiguous
9
+ end
10
+
11
+ def ambiguous?
12
+ @ambiguous
13
+ end
14
+
15
+ def *(other)
16
+ Tick.new(@time * other, @ambiguous)
17
+ end
18
+
19
+ def to_f
20
+ @time.to_f
21
+ end
22
+
23
+ def to_s
24
+ @time.to_s + (@ambiguous ? '?' : '')
25
+ end
26
+
24
27
  end
25
- end
26
-
27
- def initialize(time, options = {})
28
- t = time.gsub(/\:/, '')
29
- @type =
30
- if (1..2) === t.size
31
- hours = t.to_i
32
- hours == 12 ? Tick.new(0 * 60 * 60, true) : Tick.new(hours * 60 * 60, true)
33
- elsif t.size == 3
34
- Tick.new((t[0..0].to_i * 60 * 60) + (t[1..2].to_i * 60), true)
35
- elsif t.size == 4
36
- ambiguous = time =~ /:/ && t[0..0].to_i != 0 && t[0..1].to_i <= 12
37
- hours = t[0..1].to_i
38
- hours == 12 ? Tick.new(0 * 60 * 60 + t[2..3].to_i * 60, ambiguous) : Tick.new(hours * 60 * 60 + t[2..3].to_i * 60, ambiguous)
39
- elsif t.size == 5
40
- Tick.new(t[0..0].to_i * 60 * 60 + t[1..2].to_i * 60 + t[3..4].to_i, true)
41
- elsif t.size == 6
42
- ambiguous = time =~ /:/ && t[0..0].to_i != 0 && t[0..1].to_i <= 12
43
- hours = t[0..1].to_i
44
- hours == 12 ? Tick.new(0 * 60 * 60 + t[2..3].to_i * 60 + t[4..5].to_i, ambiguous) : Tick.new(hours * 60 * 60 + t[2..3].to_i * 60 + t[4..5].to_i, ambiguous)
45
- else
46
- raise("Time cannot exceed six digits")
28
+
29
+ def initialize(time)
30
+ @current_time = nil
31
+ t = time.gsub(/\:/, '')
32
+
33
+ @type =
34
+ case t.size
35
+ when 1..2
36
+ hours = t.to_i
37
+ hours == 12 ? Tick.new(0 * 60 * 60, true) : Tick.new(hours * 60 * 60, true)
38
+ when 3
39
+ hours = t[0..0].to_i
40
+ ambiguous = hours > 1
41
+ Tick.new((hours * 60 * 60) + (t[1..2].to_i * 60), ambiguous)
42
+ when 4
43
+ ambiguous = time =~ /:/ && t[0..0].to_i != 0 && t[0..1].to_i <= 12
44
+ hours = t[0..1].to_i
45
+ hours == 12 ? Tick.new(0 * 60 * 60 + t[2..3].to_i * 60, ambiguous) : Tick.new(hours * 60 * 60 + t[2..3].to_i * 60, ambiguous)
46
+ when 5
47
+ Tick.new(t[0..0].to_i * 60 * 60 + t[1..2].to_i * 60 + t[3..4].to_i, true)
48
+ when 6
49
+ ambiguous = time =~ /:/ && t[0..0].to_i != 0 && t[0..1].to_i <= 12
50
+ hours = t[0..1].to_i
51
+ hours == 12 ? Tick.new(0 * 60 * 60 + t[2..3].to_i * 60 + t[4..5].to_i, ambiguous) : Tick.new(hours * 60 * 60 + t[2..3].to_i * 60 + t[4..5].to_i, ambiguous)
52
+ else
53
+ raise("Time cannot exceed six digits")
54
+ end
47
55
  end
48
- end
49
-
50
- # Return the next past or future Span for the time that this Repeater represents
51
- # pointer - Symbol representing which temporal direction to fetch the next day
52
- # must be either :past or :future
53
- def next(pointer)
54
- super
55
-
56
- half_day = 60 * 60 * 12
57
- full_day = 60 * 60 * 24
58
-
59
- first = false
60
-
61
- unless @current_time
62
- first = true
63
- midnight = Time.local(@now.year, @now.month, @now.day)
64
- yesterday_midnight = midnight - full_day
65
- tomorrow_midnight = midnight + full_day
66
-
67
- catch :done do
68
- if pointer == :future
69
- if @type.ambiguous?
70
- [midnight + @type, midnight + half_day + @type, tomorrow_midnight + @type].each do |t|
71
- (@current_time = t; throw :done) if t >= @now
72
- end
73
- else
74
- [midnight + @type, tomorrow_midnight + @type].each do |t|
75
- (@current_time = t; throw :done) if t >= @now
76
- end
77
- end
78
- else # pointer == :past
79
- if @type.ambiguous?
80
- [midnight + half_day + @type, midnight + @type, yesterday_midnight + @type * 2].each do |t|
81
- (@current_time = t; throw :done) if t <= @now
56
+
57
+ # Return the next past or future Span for the time that this Repeater represents
58
+ # pointer - Symbol representing which temporal direction to fetch the next day
59
+ # must be either :past or :future
60
+ def next(pointer)
61
+ super
62
+
63
+ half_day = 60 * 60 * 12
64
+ full_day = 60 * 60 * 24
65
+
66
+ first = false
67
+
68
+ unless @current_time
69
+ first = true
70
+ midnight = Chronic.time_class.local(@now.year, @now.month, @now.day)
71
+
72
+ yesterday_midnight = midnight - full_day
73
+ tomorrow_midnight = midnight + full_day
74
+
75
+ offset_fix = midnight.gmt_offset - tomorrow_midnight.gmt_offset
76
+ tomorrow_midnight += offset_fix
77
+
78
+ catch :done do
79
+ if pointer == :future
80
+ if @type.ambiguous?
81
+ [midnight + @type.time + offset_fix, midnight + half_day + @type.time + offset_fix, tomorrow_midnight + @type.time].each do |t|
82
+ (@current_time = t; throw :done) if t >= @now
83
+ end
84
+ else
85
+ [midnight + @type.time + offset_fix, tomorrow_midnight + @type.time].each do |t|
86
+ (@current_time = t; throw :done) if t >= @now
87
+ end
82
88
  end
83
- else
84
- [midnight + @type, yesterday_midnight + @type].each do |t|
85
- (@current_time = t; throw :done) if t <= @now
89
+ else # pointer == :past
90
+ if @type.ambiguous?
91
+ [midnight + half_day + @type.time + offset_fix, midnight + @type.time + offset_fix, yesterday_midnight + @type.time + half_day].each do |t|
92
+ (@current_time = t; throw :done) if t <= @now
93
+ end
94
+ else
95
+ [midnight + @type.time + offset_fix, yesterday_midnight + @type.time].each do |t|
96
+ (@current_time = t; throw :done) if t <= @now
97
+ end
86
98
  end
87
99
  end
88
100
  end
101
+
102
+ @current_time || raise("Current time cannot be nil at this point")
89
103
  end
90
-
91
- @current_time || raise("Current time cannot be nil at this point")
104
+
105
+ unless first
106
+ increment = @type.ambiguous? ? half_day : full_day
107
+ @current_time += pointer == :future ? increment : -increment
108
+ end
109
+
110
+ Span.new(@current_time, @current_time + width)
92
111
  end
93
-
94
- unless first
95
- increment = @type.ambiguous? ? half_day : full_day
96
- @current_time += pointer == :future ? increment : -increment
112
+
113
+ def this(context = :future)
114
+ super
115
+
116
+ context = :future if context == :none
117
+
118
+ self.next(context)
119
+ end
120
+
121
+ def width
122
+ 1
123
+ end
124
+
125
+ def to_s
126
+ super << '-time-' << @type.to_s
97
127
  end
98
-
99
- Chronic::Span.new(@current_time, @current_time + width)
100
- end
101
-
102
- def this(context = :future)
103
- super
104
-
105
- context = :future if context == :none
106
-
107
- self.next(context)
108
- end
109
-
110
- def width
111
- 1
112
- end
113
-
114
- def to_s
115
- super << '-time-' << @type.to_s
116
128
  end
117
129
  end
@@ -1,68 +1,75 @@
1
- class Chronic::RepeaterWeek < Chronic::Repeater #:nodoc:
2
- WEEK_SECONDS = 604800 # (7 * 24 * 60 * 60)
3
-
4
- def next(pointer)
5
- super
6
-
7
- if !@current_week_start
1
+ module Chronic
2
+ class RepeaterWeek < Repeater #:nodoc:
3
+ WEEK_SECONDS = 604800 # (7 * 24 * 60 * 60)
4
+
5
+ def initialize(type)
6
+ super
7
+ @current_week_start = nil
8
+ end
9
+
10
+ def next(pointer)
11
+ super
12
+
13
+ if !@current_week_start
14
+ case pointer
15
+ when :future
16
+ sunday_repeater = RepeaterDayName.new(:sunday)
17
+ sunday_repeater.start = @now
18
+ next_sunday_span = sunday_repeater.next(:future)
19
+ @current_week_start = next_sunday_span.begin
20
+ when :past
21
+ sunday_repeater = RepeaterDayName.new(:sunday)
22
+ sunday_repeater.start = (@now + RepeaterDay::DAY_SECONDS)
23
+ sunday_repeater.next(:past)
24
+ last_sunday_span = sunday_repeater.next(:past)
25
+ @current_week_start = last_sunday_span.begin
26
+ end
27
+ else
28
+ direction = pointer == :future ? 1 : -1
29
+ @current_week_start += direction * WEEK_SECONDS
30
+ end
31
+
32
+ Span.new(@current_week_start, @current_week_start + WEEK_SECONDS)
33
+ end
34
+
35
+ def this(pointer = :future)
36
+ super
37
+
8
38
  case pointer
9
39
  when :future
10
- sunday_repeater = Chronic::RepeaterDayName.new(:sunday)
40
+ this_week_start = Chronic.time_class.local(@now.year, @now.month, @now.day, @now.hour) + RepeaterHour::HOUR_SECONDS
41
+ sunday_repeater = RepeaterDayName.new(:sunday)
11
42
  sunday_repeater.start = @now
12
- next_sunday_span = sunday_repeater.next(:future)
13
- @current_week_start = next_sunday_span.begin
43
+ this_sunday_span = sunday_repeater.this(:future)
44
+ this_week_end = this_sunday_span.begin
45
+ Span.new(this_week_start, this_week_end)
14
46
  when :past
15
- sunday_repeater = Chronic::RepeaterDayName.new(:sunday)
16
- sunday_repeater.start = (@now + Chronic::RepeaterDay::DAY_SECONDS)
17
- sunday_repeater.next(:past)
47
+ this_week_end = Chronic.time_class.local(@now.year, @now.month, @now.day, @now.hour)
48
+ sunday_repeater = RepeaterDayName.new(:sunday)
49
+ sunday_repeater.start = @now
50
+ last_sunday_span = sunday_repeater.next(:past)
51
+ this_week_start = last_sunday_span.begin
52
+ Span.new(this_week_start, this_week_end)
53
+ when :none
54
+ sunday_repeater = RepeaterDayName.new(:sunday)
55
+ sunday_repeater.start = @now
18
56
  last_sunday_span = sunday_repeater.next(:past)
19
- @current_week_start = last_sunday_span.begin
57
+ this_week_start = last_sunday_span.begin
58
+ Span.new(this_week_start, this_week_start + WEEK_SECONDS)
20
59
  end
21
- else
60
+ end
61
+
62
+ def offset(span, amount, pointer)
22
63
  direction = pointer == :future ? 1 : -1
23
- @current_week_start += direction * WEEK_SECONDS
64
+ span + direction * amount * WEEK_SECONDS
24
65
  end
25
-
26
- Chronic::Span.new(@current_week_start, @current_week_start + WEEK_SECONDS)
27
- end
28
-
29
- def this(pointer = :future)
30
- super
31
-
32
- case pointer
33
- when :future
34
- this_week_start = Time.local(@now.year, @now.month, @now.day, @now.hour) + Chronic::RepeaterHour::HOUR_SECONDS
35
- sunday_repeater = Chronic::RepeaterDayName.new(:sunday)
36
- sunday_repeater.start = @now
37
- this_sunday_span = sunday_repeater.this(:future)
38
- this_week_end = this_sunday_span.begin
39
- Chronic::Span.new(this_week_start, this_week_end)
40
- when :past
41
- this_week_end = Time.local(@now.year, @now.month, @now.day, @now.hour)
42
- sunday_repeater = Chronic::RepeaterDayName.new(:sunday)
43
- sunday_repeater.start = @now
44
- last_sunday_span = sunday_repeater.next(:past)
45
- this_week_start = last_sunday_span.begin
46
- Chronic::Span.new(this_week_start, this_week_end)
47
- when :none
48
- sunday_repeater = Chronic::RepeaterDayName.new(:sunday)
49
- sunday_repeater.start = @now
50
- last_sunday_span = sunday_repeater.next(:past)
51
- this_week_start = last_sunday_span.begin
52
- Chronic::Span.new(this_week_start, this_week_start + WEEK_SECONDS)
66
+
67
+ def width
68
+ WEEK_SECONDS
69
+ end
70
+
71
+ def to_s
72
+ super << '-week'
53
73
  end
54
- end
55
-
56
- def offset(span, amount, pointer)
57
- direction = pointer == :future ? 1 : -1
58
- span + direction * amount * WEEK_SECONDS
59
- end
60
-
61
- def width
62
- WEEK_SECONDS
63
- end
64
-
65
- def to_s
66
- super << '-week'
67
74
  end
68
75
  end
@@ -0,0 +1,86 @@
1
+ module Chronic
2
+ class RepeaterWeekday < Repeater #:nodoc:
3
+ DAY_SECONDS = 86400 # (24 * 60 * 60)
4
+ DAYS = {
5
+ :sunday => 0,
6
+ :monday => 1,
7
+ :tuesday => 2,
8
+ :wednesday => 3,
9
+ :thursday => 4,
10
+ :friday => 5,
11
+ :saturday => 6
12
+ }
13
+
14
+ def initialize(type)
15
+ super
16
+ @current_weekday_start = nil
17
+ end
18
+
19
+ def next(pointer)
20
+ super
21
+
22
+ direction = pointer == :future ? 1 : -1
23
+
24
+ if !@current_weekday_start
25
+ @current_weekday_start = Time.construct(@now.year, @now.month, @now.day)
26
+ @current_weekday_start += direction * DAY_SECONDS
27
+
28
+ until is_weekday?(@current_weekday_start.wday)
29
+ @current_weekday_start += direction * DAY_SECONDS
30
+ end
31
+ else
32
+ loop do
33
+ @current_weekday_start += direction * DAY_SECONDS
34
+ break if is_weekday?(@current_weekday_start.wday)
35
+ end
36
+ end
37
+
38
+ Span.new(@current_weekday_start, @current_weekday_start + DAY_SECONDS)
39
+ end
40
+
41
+ def this(pointer = :future)
42
+ super
43
+
44
+ case pointer
45
+ when :past
46
+ self.next(:past)
47
+ when :future, :none
48
+ self.next(:future)
49
+ end
50
+ end
51
+
52
+ def offset(span, amount, pointer)
53
+ direction = pointer == :future ? 1 : -1
54
+
55
+ num_weekdays_passed = 0; offset = 0
56
+ until num_weekdays_passed == amount
57
+ offset += direction * DAY_SECONDS
58
+ num_weekdays_passed += 1 if is_weekday?((span.begin+offset).wday)
59
+ end
60
+
61
+ span + offset
62
+ end
63
+
64
+ def width
65
+ DAY_SECONDS
66
+ end
67
+
68
+ def to_s
69
+ super << '-weekday'
70
+ end
71
+
72
+ private
73
+
74
+ def is_weekend?(day)
75
+ day == symbol_to_number(:saturday) || day == symbol_to_number(:sunday)
76
+ end
77
+
78
+ def is_weekday?(day)
79
+ !is_weekend?(day)
80
+ end
81
+
82
+ def symbol_to_number(sym)
83
+ DAYS[sym] || raise("Invalid symbol specified")
84
+ end
85
+ end
86
+ end
@@ -1,60 +1,67 @@
1
- class Chronic::RepeaterWeekend < Chronic::Repeater #:nodoc:
2
- WEEKEND_SECONDS = 172_800 # (2 * 24 * 60 * 60)
3
-
4
- def next(pointer)
5
- super
6
-
7
- if !@current_week_start
1
+ module Chronic
2
+ class RepeaterWeekend < Repeater #:nodoc:
3
+ WEEKEND_SECONDS = 172_800 # (2 * 24 * 60 * 60)
4
+
5
+ def initialize(type)
6
+ super
7
+ @current_week_start = nil
8
+ end
9
+
10
+ def next(pointer)
11
+ super
12
+
13
+ if !@current_week_start
14
+ case pointer
15
+ when :future
16
+ saturday_repeater = RepeaterDayName.new(:saturday)
17
+ saturday_repeater.start = @now
18
+ next_saturday_span = saturday_repeater.next(:future)
19
+ @current_week_start = next_saturday_span.begin
20
+ when :past
21
+ saturday_repeater = RepeaterDayName.new(:saturday)
22
+ saturday_repeater.start = (@now + RepeaterDay::DAY_SECONDS)
23
+ last_saturday_span = saturday_repeater.next(:past)
24
+ @current_week_start = last_saturday_span.begin
25
+ end
26
+ else
27
+ direction = pointer == :future ? 1 : -1
28
+ @current_week_start += direction * RepeaterWeek::WEEK_SECONDS
29
+ end
30
+
31
+ Span.new(@current_week_start, @current_week_start + WEEKEND_SECONDS)
32
+ end
33
+
34
+ def this(pointer = :future)
35
+ super
36
+
8
37
  case pointer
9
- when :future
10
- saturday_repeater = Chronic::RepeaterDayName.new(:saturday)
38
+ when :future, :none
39
+ saturday_repeater = RepeaterDayName.new(:saturday)
11
40
  saturday_repeater.start = @now
12
- next_saturday_span = saturday_repeater.next(:future)
13
- @current_week_start = next_saturday_span.begin
41
+ this_saturday_span = saturday_repeater.this(:future)
42
+ Span.new(this_saturday_span.begin, this_saturday_span.begin + WEEKEND_SECONDS)
14
43
  when :past
15
- saturday_repeater = Chronic::RepeaterDayName.new(:saturday)
16
- saturday_repeater.start = (@now + Chronic::RepeaterDay::DAY_SECONDS)
17
- last_saturday_span = saturday_repeater.next(:past)
18
- @current_week_start = last_saturday_span.begin
44
+ saturday_repeater = RepeaterDayName.new(:saturday)
45
+ saturday_repeater.start = @now
46
+ last_saturday_span = saturday_repeater.this(:past)
47
+ Span.new(last_saturday_span.begin, last_saturday_span.begin + WEEKEND_SECONDS)
19
48
  end
20
- else
49
+ end
50
+
51
+ def offset(span, amount, pointer)
21
52
  direction = pointer == :future ? 1 : -1
22
- @current_week_start += direction * Chronic::RepeaterWeek::WEEK_SECONDS
53
+ weekend = RepeaterWeekend.new(:weekend)
54
+ weekend.start = span.begin
55
+ start = weekend.next(pointer).begin + (amount - 1) * direction * RepeaterWeek::WEEK_SECONDS
56
+ Span.new(start, start + (span.end - span.begin))
23
57
  end
24
-
25
- Chronic::Span.new(@current_week_start, @current_week_start + WEEKEND_SECONDS)
26
- end
27
-
28
- def this(pointer = :future)
29
- super
30
-
31
- case pointer
32
- when :future, :none
33
- saturday_repeater = Chronic::RepeaterDayName.new(:saturday)
34
- saturday_repeater.start = @now
35
- this_saturday_span = saturday_repeater.this(:future)
36
- Chronic::Span.new(this_saturday_span.begin, this_saturday_span.begin + WEEKEND_SECONDS)
37
- when :past
38
- saturday_repeater = Chronic::RepeaterDayName.new(:saturday)
39
- saturday_repeater.start = @now
40
- last_saturday_span = saturday_repeater.this(:past)
41
- Chronic::Span.new(last_saturday_span.begin, last_saturday_span.begin + WEEKEND_SECONDS)
58
+
59
+ def width
60
+ WEEKEND_SECONDS
61
+ end
62
+
63
+ def to_s
64
+ super << '-weekend'
42
65
  end
43
- end
44
-
45
- def offset(span, amount, pointer)
46
- direction = pointer == :future ? 1 : -1
47
- weekend = Chronic::RepeaterWeekend.new(:weekend)
48
- weekend.start = span.begin
49
- start = weekend.next(pointer).begin + (amount - 1) * direction * Chronic::RepeaterWeek::WEEK_SECONDS
50
- Chronic::Span.new(start, start + (span.end - span.begin))
51
- end
52
-
53
- def width
54
- WEEKEND_SECONDS
55
- end
56
-
57
- def to_s
58
- super << '-weekend'
59
66
  end
60
67
  end