chronic 0.1.5 → 0.6.5

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 (68) hide show
  1. data/.gemtest +0 -0
  2. data/.gitignore +5 -0
  3. data/.yardopts +3 -0
  4. data/HISTORY.md +180 -0
  5. data/LICENSE +21 -0
  6. data/README.md +176 -0
  7. data/Rakefile +39 -32
  8. data/chronic.gemspec +17 -0
  9. data/lib/chronic/chronic.rb +294 -208
  10. data/lib/chronic/grabber.rb +22 -17
  11. data/lib/chronic/handler.rb +90 -0
  12. data/lib/chronic/handlers.rb +365 -278
  13. data/lib/chronic/mini_date.rb +38 -0
  14. data/lib/chronic/numerizer.rb +121 -0
  15. data/lib/chronic/ordinal.rb +23 -19
  16. data/lib/chronic/pointer.rb +20 -17
  17. data/lib/chronic/repeater.rb +126 -105
  18. data/lib/chronic/repeaters/repeater_day.rb +49 -43
  19. data/lib/chronic/repeaters/repeater_day_name.rb +48 -42
  20. data/lib/chronic/repeaters/repeater_day_portion.rb +81 -80
  21. data/lib/chronic/repeaters/repeater_fortnight.rb +59 -53
  22. data/lib/chronic/repeaters/repeater_hour.rb +49 -43
  23. data/lib/chronic/repeaters/repeater_minute.rb +55 -39
  24. data/lib/chronic/repeaters/repeater_month.rb +77 -55
  25. data/lib/chronic/repeaters/repeater_month_name.rb +83 -82
  26. data/lib/chronic/repeaters/repeater_season.rb +107 -21
  27. data/lib/chronic/repeaters/repeater_season_name.rb +41 -22
  28. data/lib/chronic/repeaters/repeater_second.rb +39 -33
  29. data/lib/chronic/repeaters/repeater_time.rb +117 -103
  30. data/lib/chronic/repeaters/repeater_week.rb +63 -57
  31. data/lib/chronic/repeaters/repeater_weekday.rb +85 -0
  32. data/lib/chronic/repeaters/repeater_weekend.rb +64 -9
  33. data/lib/chronic/repeaters/repeater_year.rb +70 -51
  34. data/lib/chronic/scalar.rb +64 -29
  35. data/lib/chronic/season.rb +37 -0
  36. data/lib/chronic/separator.rb +50 -38
  37. data/lib/chronic/span.rb +31 -0
  38. data/lib/chronic/tag.rb +42 -0
  39. data/lib/chronic/time_zone.rb +30 -0
  40. data/lib/chronic/token.rb +45 -0
  41. data/lib/chronic.rb +86 -22
  42. data/test/helper.rb +6 -0
  43. data/test/test_Chronic.rb +118 -20
  44. data/test/test_DaylightSavings.rb +118 -0
  45. data/test/test_Handler.rb +36 -42
  46. data/test/test_MiniDate.rb +32 -0
  47. data/test/test_Numerizer.rb +72 -0
  48. data/test/test_RepeaterDayName.rb +15 -16
  49. data/test/test_RepeaterFortnight.rb +16 -17
  50. data/test/test_RepeaterHour.rb +22 -19
  51. data/test/test_RepeaterMinute.rb +34 -0
  52. data/test/test_RepeaterMonth.rb +20 -17
  53. data/test/test_RepeaterMonthName.rb +17 -18
  54. data/test/test_RepeaterSeason.rb +40 -0
  55. data/test/test_RepeaterTime.rb +20 -22
  56. data/test/test_RepeaterWeek.rb +16 -17
  57. data/test/test_RepeaterWeekday.rb +55 -0
  58. data/test/test_RepeaterWeekend.rb +74 -0
  59. data/test/test_RepeaterYear.rb +24 -18
  60. data/test/test_Span.rb +5 -6
  61. data/test/test_Token.rb +5 -6
  62. data/test/test_parsing.rb +743 -338
  63. metadata +81 -54
  64. data/History.txt +0 -29
  65. data/Manifest.txt +0 -43
  66. data/README.txt +0 -149
  67. data/test/parse_numbers.rb +0 -50
  68. data/test/suite.rb +0 -9
@@ -1,46 +1,52 @@
1
- class Chronic::RepeaterDayName < Chronic::Repeater #:nodoc:
2
- DAY_SECONDS = 86400 # (24 * 60 * 60)
3
-
4
- def next(pointer)
5
- super
6
-
7
- direction = pointer == :future ? 1 : -1
8
-
9
- if !@current_day_start
10
- @current_day_start = Time.local(@now.year, @now.month, @now.day)
11
- @current_day_start += direction * DAY_SECONDS
12
-
13
- day_num = symbol_to_number(@type)
14
-
15
- while @current_day_start.wday != day_num
16
- @current_day_start += direction * DAY_SECONDS
1
+ module Chronic
2
+ class RepeaterDayName < Repeater #:nodoc:
3
+ DAY_SECONDS = 86400 # (24 * 60 * 60)
4
+
5
+ def initialize(type)
6
+ super
7
+ end
8
+
9
+ def next(pointer)
10
+ super
11
+
12
+ direction = pointer == :future ? 1 : -1
13
+
14
+ if !@current_date
15
+ @current_date = Date.new(@now.year, @now.month, @now.day)
16
+ @current_date += direction
17
+
18
+ day_num = symbol_to_number(@type)
19
+
20
+ while @current_date.wday != day_num
21
+ @current_date += direction
22
+ end
23
+ else
24
+ @current_date += direction * 7
17
25
  end
18
- else
19
- @current_day_start += direction * 7 * DAY_SECONDS
26
+ next_date = @current_date.succ
27
+ Span.new(Chronic.construct(@current_date.year, @current_date.month, @current_date.day), Chronic.construct(next_date.year, next_date.month, next_date.day))
28
+ end
29
+
30
+ def this(pointer = :future)
31
+ super
32
+
33
+ pointer = :future if pointer == :none
34
+ self.next(pointer)
35
+ end
36
+
37
+ def width
38
+ DAY_SECONDS
39
+ end
40
+
41
+ def to_s
42
+ super << '-dayname-' << @type.to_s
43
+ end
44
+
45
+ private
46
+
47
+ def symbol_to_number(sym)
48
+ lookup = {:sunday => 0, :monday => 1, :tuesday => 2, :wednesday => 3, :thursday => 4, :friday => 5, :saturday => 6}
49
+ lookup[sym] || raise("Invalid symbol specified")
20
50
  end
21
-
22
- Chronic::Span.new(@current_day_start, @current_day_start + DAY_SECONDS)
23
- end
24
-
25
- def this(pointer = :future)
26
- super
27
-
28
- pointer = :future if pointer == :none
29
- self.next(pointer)
30
- end
31
-
32
- def width
33
- DAY_SECONDS
34
- end
35
-
36
- def to_s
37
- super << '-dayofweek-' << @type.to_s
38
- end
39
-
40
- private
41
-
42
- def symbol_to_number(sym)
43
- lookup = {:sunday => 0, :monday => 1, :tuesday => 2, :wednesday => 3, :thursday => 4, :friday => 5, :saturday => 6}
44
- lookup[sym] || raise("Invalid symbol specified")
45
51
  end
46
52
  end
@@ -1,93 +1,94 @@
1
- class Chronic::RepeaterDayPortion < Chronic::Repeater #:nodoc:
2
- @@morning = (6 * 60 * 60)..(12 * 60 * 60) # 6am-12am
3
- @@afternoon = (13 * 60 * 60)..(17 * 60 * 60) # 1pm-5pm
4
- @@evening = (17 * 60 * 60)..(20 * 60 * 60) # 5pm-8pm
5
- @@night = (20 * 60 * 60)..(24 * 60 * 60) # 8pm-12pm
6
-
7
- def initialize(type)
8
- super
9
-
10
- if type.kind_of? Integer
11
- @range = (@type * 60 * 60)..((@type + 12) * 60 * 60)
12
- else
13
- lookup = {:am => 1..(12 * 60 * 60),
14
- :pm => (12 * 60 * 60)..(24 * 60 * 60),
15
- :morning => @@morning,
16
- :afternoon => @@afternoon,
17
- :evening => @@evening,
18
- :night => @@night}
19
- @range = lookup[type]
20
- lookup[type] || raise("Invalid type '#{type}' for RepeaterDayPortion")
1
+ module Chronic
2
+ class RepeaterDayPortion < Repeater #:nodoc:
3
+ PORTIONS = {
4
+ :am => 0..(12 * 60 * 60 - 1),
5
+ :pm => (12 * 60 * 60)..(24 * 60 * 60 - 1),
6
+ :morning => (6 * 60 * 60)..(12 * 60 * 60), # 6am-12am,
7
+ :afternoon => (13 * 60 * 60)..(17 * 60 * 60), # 1pm-5pm,
8
+ :evening => (17 * 60 * 60)..(20 * 60 * 60), # 5pm-8pm,
9
+ :night => (20 * 60 * 60)..(24 * 60 * 60), # 8pm-12pm
10
+ }
11
+
12
+ def initialize(type)
13
+ super
14
+
15
+ if type.kind_of? Integer
16
+ @range = (@type * 60 * 60)..((@type + 12) * 60 * 60)
17
+ else
18
+ @range = PORTIONS[type]
19
+ @range || raise("Invalid type '#{type}' for RepeaterDayPortion")
20
+ end
21
+
22
+ @range || raise("Range should have been set by now")
21
23
  end
22
- @range || raise("Range should have been set by now")
23
- end
24
-
25
- def next(pointer)
26
- super
27
-
28
- full_day = 60 * 60 * 24
29
-
30
- if !@current_span
31
- now_seconds = @now - Time.local(@now.year, @now.month, @now.day)
32
- if now_seconds < @range.begin
33
- case pointer
34
- when :future
35
- range_start = Time.local(@now.year, @now.month, @now.day) + @range.begin
36
- when :past
37
- range_start = Time.local(@now.year, @now.month, @now.day) - full_day + @range.begin
38
- end
39
- elsif now_seconds > @range.end
40
- case pointer
41
- when :future
42
- range_start = Time.local(@now.year, @now.month, @now.day) + full_day + @range.begin
43
- when :past
44
- range_start = Time.local(@now.year, @now.month, @now.day) + @range.begin
24
+
25
+ def next(pointer)
26
+ super
27
+
28
+ full_day = 60 * 60 * 24
29
+
30
+ if !@current_span
31
+ now_seconds = @now - Chronic.construct(@now.year, @now.month, @now.day)
32
+ if now_seconds < @range.begin
33
+ case pointer
34
+ when :future
35
+ range_start = Chronic.construct(@now.year, @now.month, @now.day) + @range.begin
36
+ when :past
37
+ range_start = Chronic.construct(@now.year, @now.month, @now.day) - full_day + @range.begin
38
+ end
39
+ elsif now_seconds > @range.end
40
+ case pointer
41
+ when :future
42
+ range_start = Chronic.construct(@now.year, @now.month, @now.day) + full_day + @range.begin
43
+ when :past
44
+ range_start = Chronic.construct(@now.year, @now.month, @now.day) + @range.begin
45
+ end
46
+ else
47
+ case pointer
48
+ when :future
49
+ range_start = Chronic.construct(@now.year, @now.month, @now.day) + full_day + @range.begin
50
+ when :past
51
+ range_start = Chronic.construct(@now.year, @now.month, @now.day) - full_day + @range.begin
52
+ end
45
53
  end
54
+
55
+ @current_span = Span.new(range_start, range_start + (@range.end - @range.begin))
46
56
  else
47
57
  case pointer
48
58
  when :future
49
- range_start = Time.local(@now.year, @now.month, @now.day) + full_day + @range.begin
59
+ @current_span += full_day
50
60
  when :past
51
- range_start = Time.local(@now.year, @now.month, @now.day) - full_day + @range.begin
61
+ @current_span -= full_day
52
62
  end
53
63
  end
54
-
55
- @current_span = Chronic::Span.new(range_start, range_start + (@range.end - @range.begin))
56
- else
57
- case pointer
58
- when :future
59
- @current_span += full_day
60
- when :past
61
- @current_span -= full_day
64
+ end
65
+
66
+ def this(context = :future)
67
+ super
68
+
69
+ range_start = Chronic.construct(@now.year, @now.month, @now.day) + @range.begin
70
+ @current_span = Span.new(range_start, range_start + (@range.end - @range.begin))
71
+ end
72
+
73
+ def offset(span, amount, pointer)
74
+ @now = span.begin
75
+ portion_span = self.next(pointer)
76
+ direction = pointer == :future ? 1 : -1
77
+ portion_span + (direction * (amount - 1) * RepeaterDay::DAY_SECONDS)
78
+ end
79
+
80
+ def width
81
+ @range || raise("Range has not been set")
82
+ return @current_span.width if @current_span
83
+ if @type.kind_of? Integer
84
+ return (12 * 60 * 60)
85
+ else
86
+ @range.end - @range.begin
62
87
  end
63
88
  end
64
- end
65
-
66
- def this(context = :future)
67
- super
68
-
69
- range_start = Time.local(@now.year, @now.month, @now.day) + @range.begin
70
- @current_span = Chronic::Span.new(range_start, range_start + (@range.end - @range.begin))
71
- end
72
-
73
- def offset(span, amount, pointer)
74
- @now = span.begin
75
- portion_span = self.next(pointer)
76
- direction = pointer == :future ? 1 : -1
77
- portion_span + (direction * (amount - 1) * Chronic::RepeaterDay::DAY_SECONDS)
78
- end
79
-
80
- def width
81
- @range || raise("Range has not been set")
82
- return @current_span.width if @current_span
83
- if @type.kind_of? Integer
84
- return (12 * 60 * 60)
85
- else
86
- @range.end - @range.begin
89
+
90
+ def to_s
91
+ super << '-dayportion-' << @type.to_s
87
92
  end
88
93
  end
89
-
90
- def to_s
91
- super << '-dayportion-' << @type.to_s
92
- end
93
94
  end
@@ -1,65 +1,71 @@
1
- class Chronic::RepeaterFortnight < Chronic::Repeater #:nodoc:
2
- FORTNIGHT_SECONDS = 1_209_600 # (14 * 24 * 60 * 60)
3
-
4
- def next(pointer)
5
- super
6
-
7
- if !@current_fortnight_start
1
+ module Chronic
2
+ class RepeaterFortnight < Repeater #:nodoc:
3
+ FORTNIGHT_SECONDS = 1_209_600 # (14 * 24 * 60 * 60)
4
+
5
+ def initialize(type)
6
+ super
7
+ end
8
+
9
+ def next(pointer)
10
+ super
11
+
12
+ if !@current_fortnight_start
13
+ case pointer
14
+ when :future
15
+ sunday_repeater = RepeaterDayName.new(:sunday)
16
+ sunday_repeater.start = @now
17
+ next_sunday_span = sunday_repeater.next(:future)
18
+ @current_fortnight_start = next_sunday_span.begin
19
+ when :past
20
+ sunday_repeater = RepeaterDayName.new(:sunday)
21
+ sunday_repeater.start = (@now + RepeaterDay::DAY_SECONDS)
22
+ 2.times { sunday_repeater.next(:past) }
23
+ last_sunday_span = sunday_repeater.next(:past)
24
+ @current_fortnight_start = last_sunday_span.begin
25
+ end
26
+ else
27
+ direction = pointer == :future ? 1 : -1
28
+ @current_fortnight_start += direction * FORTNIGHT_SECONDS
29
+ end
30
+
31
+ Span.new(@current_fortnight_start, @current_fortnight_start + FORTNIGHT_SECONDS)
32
+ end
33
+
34
+ def this(pointer = :future)
35
+ super
36
+
37
+ pointer = :future if pointer == :none
38
+
8
39
  case pointer
9
40
  when :future
10
- sunday_repeater = Chronic::RepeaterDayName.new(:sunday)
41
+ this_fortnight_start = Chronic.construct(@now.year, @now.month, @now.day, @now.hour) + RepeaterHour::HOUR_SECONDS
42
+ sunday_repeater = RepeaterDayName.new(:sunday)
11
43
  sunday_repeater.start = @now
12
- next_sunday_span = sunday_repeater.next(:future)
13
- @current_fortnight_start = next_sunday_span.begin
44
+ sunday_repeater.this(:future)
45
+ this_sunday_span = sunday_repeater.this(:future)
46
+ this_fortnight_end = this_sunday_span.begin
47
+ Span.new(this_fortnight_start, this_fortnight_end)
14
48
  when :past
15
- sunday_repeater = Chronic::RepeaterDayName.new(:sunday)
16
- sunday_repeater.start = (@now + Chronic::RepeaterDay::DAY_SECONDS)
17
- 2.times { sunday_repeater.next(:past) }
49
+ this_fortnight_end = Chronic.construct(@now.year, @now.month, @now.day, @now.hour)
50
+ sunday_repeater = RepeaterDayName.new(:sunday)
51
+ sunday_repeater.start = @now
18
52
  last_sunday_span = sunday_repeater.next(:past)
19
- @current_fortnight_start = last_sunday_span.begin
53
+ this_fortnight_start = last_sunday_span.begin
54
+ Span.new(this_fortnight_start, this_fortnight_end)
20
55
  end
21
- else
56
+ end
57
+
58
+ def offset(span, amount, pointer)
22
59
  direction = pointer == :future ? 1 : -1
23
- @current_fortnight_start += direction * FORTNIGHT_SECONDS
60
+ span + direction * amount * FORTNIGHT_SECONDS
24
61
  end
25
-
26
- Chronic::Span.new(@current_fortnight_start, @current_fortnight_start + FORTNIGHT_SECONDS)
27
- end
28
-
29
- def this(pointer = :future)
30
- super
31
-
32
- pointer = :future if pointer == :none
33
-
34
- case pointer
35
- when :future
36
- this_fortnight_start = Time.local(@now.year, @now.month, @now.day, @now.hour) + Chronic::RepeaterHour::HOUR_SECONDS
37
- sunday_repeater = Chronic::RepeaterDayName.new(:sunday)
38
- sunday_repeater.start = @now
39
- sunday_repeater.this(:future)
40
- this_sunday_span = sunday_repeater.this(:future)
41
- this_fortnight_end = this_sunday_span.begin
42
- Chronic::Span.new(this_fortnight_start, this_fortnight_end)
43
- when :past
44
- this_fortnight_end = Time.local(@now.year, @now.month, @now.day, @now.hour)
45
- sunday_repeater = Chronic::RepeaterDayName.new(:sunday)
46
- sunday_repeater.start = @now
47
- last_sunday_span = sunday_repeater.next(:past)
48
- this_fortnight_start = last_sunday_span.begin
49
- Chronic::Span.new(this_fortnight_start, this_fortnight_end)
62
+
63
+ def width
64
+ FORTNIGHT_SECONDS
50
65
  end
51
- end
52
-
53
- def offset(span, amount, pointer)
54
- direction = pointer == :future ? 1 : -1
55
- span + direction * amount * FORTNIGHT_SECONDS
56
- end
57
66
 
58
- def width
59
- FORTNIGHT_SECONDS
60
- end
61
-
62
- def to_s
63
- super << '-fortnight'
67
+ def to_s
68
+ super << '-fortnight'
69
+ end
64
70
  end
65
71
  end
@@ -1,52 +1,58 @@
1
- class Chronic::RepeaterHour < Chronic::Repeater #:nodoc:
2
- HOUR_SECONDS = 3600 # 60 * 60
3
-
4
- def next(pointer)
5
- super
6
-
7
- if !@current_hour_start
1
+ module Chronic
2
+ class RepeaterHour < Repeater #:nodoc:
3
+ HOUR_SECONDS = 3600 # 60 * 60
4
+
5
+ def initialize(type)
6
+ super
7
+ end
8
+
9
+ def next(pointer)
10
+ super
11
+
12
+ if !@current_hour_start
13
+ case pointer
14
+ when :future
15
+ @current_hour_start = Chronic.construct(@now.year, @now.month, @now.day, @now.hour + 1)
16
+ when :past
17
+ @current_hour_start = Chronic.construct(@now.year, @now.month, @now.day, @now.hour - 1)
18
+ end
19
+ else
20
+ direction = pointer == :future ? 1 : -1
21
+ @current_hour_start += direction * HOUR_SECONDS
22
+ end
23
+
24
+ Span.new(@current_hour_start, @current_hour_start + HOUR_SECONDS)
25
+ end
26
+
27
+ def this(pointer = :future)
28
+ super
29
+
8
30
  case pointer
9
31
  when :future
10
- @current_hour_start = Time.local(@now.year, @now.month, @now.day, @now.hour + 1)
32
+ hour_start = Chronic.construct(@now.year, @now.month, @now.day, @now.hour, @now.min + 1)
33
+ hour_end = Chronic.construct(@now.year, @now.month, @now.day, @now.hour + 1)
11
34
  when :past
12
- @current_hour_start = Time.local(@now.year, @now.month, @now.day, @now.hour - 1)
35
+ hour_start = Chronic.construct(@now.year, @now.month, @now.day, @now.hour)
36
+ hour_end = Chronic.construct(@now.year, @now.month, @now.day, @now.hour, @now.min)
37
+ when :none
38
+ hour_start = Chronic.construct(@now.year, @now.month, @now.day, @now.hour)
39
+ hour_end = hour_start + HOUR_SECONDS
13
40
  end
14
- else
41
+
42
+ Span.new(hour_start, hour_end)
43
+ end
44
+
45
+ def offset(span, amount, pointer)
15
46
  direction = pointer == :future ? 1 : -1
16
- @current_hour_start += direction * HOUR_SECONDS
47
+ span + direction * amount * HOUR_SECONDS
17
48
  end
18
-
19
- Chronic::Span.new(@current_hour_start, @current_hour_start + HOUR_SECONDS)
20
- end
21
-
22
- def this(pointer = :future)
23
- super
24
-
25
- case pointer
26
- when :future
27
- hour_start = Time.local(@now.year, @now.month, @now.day, @now.hour, @now.min + 1)
28
- hour_end = Time.local(@now.year, @now.month, @now.day, @now.hour + 1)
29
- when :past
30
- hour_start = Time.local(@now.year, @now.month, @now.day, @now.hour)
31
- hour_end = Time.local(@now.year, @now.month, @now.day, @now.hour, @now.min)
32
- when :none
33
- hour_start = Time.local(@now.year, @now.month, @now.day, @now.hour)
34
- hour_end = hour_begin + HOUR_SECONDS
49
+
50
+ def width
51
+ HOUR_SECONDS
52
+ end
53
+
54
+ def to_s
55
+ super << '-hour'
35
56
  end
36
-
37
- Chronic::Span.new(hour_start, hour_end)
38
- end
39
-
40
- def offset(span, amount, pointer)
41
- direction = pointer == :future ? 1 : -1
42
- span + direction * amount * HOUR_SECONDS
43
- end
44
-
45
- def width
46
- HOUR_SECONDS
47
- end
48
-
49
- def to_s
50
- super << '-hour'
51
57
  end
52
58
  end
@@ -1,42 +1,58 @@
1
- class Chronic::RepeaterMinute < Chronic::Repeater #:nodoc:
2
- MINUTE_SECONDS = 60
3
-
4
- def next(pointer = :future)
5
- super
6
-
7
- direction = pointer == :future ? 1 : -1
8
-
9
- raise 'not implemented'
10
- end
11
-
12
- def this(pointer = :future)
13
- super
14
-
15
- case pointer
16
- when :future
17
- minute_begin = @now
18
- minute_end = Time.local(@now.year, @now.month, @now.day, @now.hour, @now.min)
19
- when :past
20
- minute_begin = Time.local(@now.year, @now.month, @now.day, @now.hour, @now.min)
21
- minute_end = @now
22
- when :none
23
- minute_begin = Time.local(@now.year, @now.month, @now.day, @now.hour, @now.min)
24
- minute_end = Time.local(@now.year, @now.month, @now.day, @now.hour, @now.min) + MINUTE_SECONDS
1
+ module Chronic
2
+ class RepeaterMinute < Repeater #:nodoc:
3
+ MINUTE_SECONDS = 60
4
+
5
+ def initialize(type)
6
+ super
7
+ end
8
+
9
+ def next(pointer = :future)
10
+ super
11
+
12
+ if !@current_minute_start
13
+ case pointer
14
+ when :future
15
+ @current_minute_start = Chronic.construct(@now.year, @now.month, @now.day, @now.hour, @now.min + 1)
16
+ when :past
17
+ @current_minute_start = Chronic.construct(@now.year, @now.month, @now.day, @now.hour, @now.min - 1)
18
+ end
19
+ else
20
+ direction = pointer == :future ? 1 : -1
21
+ @current_minute_start += direction * MINUTE_SECONDS
22
+ end
23
+
24
+ Span.new(@current_minute_start, @current_minute_start + MINUTE_SECONDS)
25
+ end
26
+
27
+ def this(pointer = :future)
28
+ super
29
+
30
+ case pointer
31
+ when :future
32
+ minute_begin = @now
33
+ minute_end = Chronic.construct(@now.year, @now.month, @now.day, @now.hour, @now.min)
34
+ when :past
35
+ minute_begin = Chronic.construct(@now.year, @now.month, @now.day, @now.hour, @now.min)
36
+ minute_end = @now
37
+ when :none
38
+ minute_begin = Chronic.construct(@now.year, @now.month, @now.day, @now.hour, @now.min)
39
+ minute_end = Chronic.construct(@now.year, @now.month, @now.day, @now.hour, @now.min) + MINUTE_SECONDS
40
+ end
41
+
42
+ Span.new(minute_begin, minute_end)
43
+ end
44
+
45
+ def offset(span, amount, pointer)
46
+ direction = pointer == :future ? 1 : -1
47
+ span + direction * amount * MINUTE_SECONDS
48
+ end
49
+
50
+ def width
51
+ MINUTE_SECONDS
52
+ end
53
+
54
+ def to_s
55
+ super << '-minute'
25
56
  end
26
-
27
- Chronic::Span.new(minute_begin, minute_end)
28
- end
29
-
30
- def offset(span, amount, pointer)
31
- direction = pointer == :future ? 1 : -1
32
- span + direction * amount * MINUTE_SECONDS
33
- end
34
-
35
- def width
36
- MINUTE_SECONDS
37
- end
38
-
39
- def to_s
40
- super << '-minute'
41
57
  end
42
58
  end