chronic 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/HISTORY.md +14 -1
- data/lib/chronic.rb +6 -42
- data/lib/chronic/chronic.rb +73 -48
- data/lib/chronic/handler.rb +90 -0
- data/lib/chronic/handlers.rb +131 -139
- data/lib/chronic/mini_date.rb +12 -6
- data/lib/chronic/numerizer.rb +3 -2
- data/lib/chronic/pointer.rb +1 -2
- data/lib/chronic/repeater.rb +3 -6
- data/lib/chronic/repeaters/repeater_day.rb +6 -6
- data/lib/chronic/repeaters/repeater_day_name.rb +1 -1
- data/lib/chronic/repeaters/repeater_day_portion.rb +8 -8
- data/lib/chronic/repeaters/repeater_fortnight.rb +2 -2
- data/lib/chronic/repeaters/repeater_hour.rb +7 -7
- data/lib/chronic/repeaters/repeater_minute.rb +6 -6
- data/lib/chronic/repeaters/repeater_month.rb +10 -10
- data/lib/chronic/repeaters/repeater_month_name.rb +9 -9
- data/lib/chronic/repeaters/repeater_season.rb +10 -10
- data/lib/chronic/repeaters/repeater_season_name.rb +2 -2
- data/lib/chronic/repeaters/repeater_weekday.rb +1 -1
- data/lib/chronic/repeaters/repeater_year.rb +11 -11
- data/lib/chronic/season.rb +3 -3
- data/lib/chronic/tag.rb +2 -0
- data/test/test_Chronic.rb +48 -4
- data/test/test_DaylightSavings.rb +1 -1
- data/test/test_Handler.rb +1 -6
- data/test/test_MiniDate.rb +3 -3
- data/test/test_Numerizer.rb +1 -1
- data/test/test_RepeaterDayName.rb +1 -1
- data/test/test_RepeaterFortnight.rb +1 -1
- data/test/test_RepeaterHour.rb +1 -1
- data/test/test_RepeaterMinute.rb +1 -1
- data/test/test_RepeaterMonth.rb +1 -1
- data/test/test_RepeaterMonthName.rb +1 -1
- data/test/test_RepeaterSeason.rb +1 -1
- data/test/test_RepeaterTime.rb +1 -1
- data/test/test_RepeaterWeek.rb +1 -1
- data/test/test_RepeaterWeekday.rb +1 -1
- data/test/test_RepeaterWeekend.rb +1 -1
- data/test/test_RepeaterYear.rb +1 -1
- data/test/test_Span.rb +1 -1
- data/test/test_Token.rb +1 -1
- data/test/test_parsing.rb +12 -6
- metadata +3 -5
- data/Manifest.txt +0 -63
- data/test/test_Time.rb +0 -49
data/lib/chronic/mini_date.rb
CHANGED
@@ -2,9 +2,13 @@ module Chronic
|
|
2
2
|
class MiniDate
|
3
3
|
attr_accessor :month, :day
|
4
4
|
|
5
|
+
def self.from_time(time)
|
6
|
+
new(time.month, time.day)
|
7
|
+
end
|
8
|
+
|
5
9
|
def initialize(month, day)
|
6
10
|
unless (1..12).include?(month)
|
7
|
-
raise
|
11
|
+
raise ArgumentError, "1..12 are valid months"
|
8
12
|
end
|
9
13
|
|
10
14
|
@month = month
|
@@ -12,11 +16,13 @@ module Chronic
|
|
12
16
|
end
|
13
17
|
|
14
18
|
def is_between?(md_start, md_end)
|
15
|
-
return false if (@month == md_start.month && @month == md_end.month &&
|
16
|
-
(@day < md_start.day || @day > md_end.day)
|
17
|
-
return true if (@month == md_start.month
|
18
|
-
(@month == md_end.month
|
19
|
+
return false if (@month == md_start.month && @month == md_end.month) &&
|
20
|
+
(@day < md_start.day || @day > md_end.day)
|
21
|
+
return true if (@month == md_start.month && @day >= md_start.day) ||
|
22
|
+
(@month == md_end.month && @day <= md_end.day)
|
23
|
+
|
19
24
|
i = (md_start.month % 12) + 1
|
25
|
+
|
20
26
|
until i == md_end.month
|
21
27
|
return true if @month == i
|
22
28
|
i = (i % 12) + 1
|
@@ -26,7 +32,7 @@ module Chronic
|
|
26
32
|
end
|
27
33
|
|
28
34
|
def equals?(other)
|
29
|
-
@month == other.month and day == other.day
|
35
|
+
@month == other.month and @day == other.day
|
30
36
|
end
|
31
37
|
end
|
32
38
|
end
|
data/lib/chronic/numerizer.rb
CHANGED
@@ -107,14 +107,15 @@ module Chronic
|
|
107
107
|
|
108
108
|
def andition(string)
|
109
109
|
sc = StringScanner.new(string)
|
110
|
-
|
110
|
+
|
111
|
+
while sc.scan_until(/<num>(\d+)( | and )<num>(\d+)(?=[^\w]|$)/i)
|
111
112
|
if sc[2] =~ /and/ || sc[1].size > sc[3].size
|
112
113
|
string[(sc.pos - sc.matched_size)..(sc.pos-1)] = '<num>' + (sc[1].to_i + sc[3].to_i).to_s
|
113
114
|
sc.reset
|
114
115
|
end
|
115
116
|
end
|
116
117
|
end
|
117
|
-
end
|
118
118
|
|
119
|
+
end
|
119
120
|
end
|
120
121
|
end
|
data/lib/chronic/pointer.rb
CHANGED
data/lib/chronic/repeater.rb
CHANGED
@@ -56,12 +56,9 @@ module Chronic
|
|
56
56
|
scan_for token, RepeaterDayName,
|
57
57
|
{
|
58
58
|
/^m[ou]n(day)?$/ => :monday,
|
59
|
-
/^t(ue|eu|oo|u|)s(day)?$/ => :tuesday,
|
60
|
-
/^
|
61
|
-
/^
|
62
|
-
/^wed$/ => :wednesday,
|
63
|
-
/^th(urs|ers)day$/ => :thursday,
|
64
|
-
/^thu(rs)?$/ => :thursday,
|
59
|
+
/^t(ue|eu|oo|u|)s?(day)?$/ => :tuesday,
|
60
|
+
/^we(d|dnes|nds|nns)(day)?$/ => :wednesday,
|
61
|
+
/^th(urs|ers)(day)?$/ => :thursday,
|
65
62
|
/^fr[iy](day)?$/ => :friday,
|
66
63
|
/^sat(t?[ue]rday)?$/ => :saturday,
|
67
64
|
/^su[nm](day)?$/ => :sunday
|
@@ -24,14 +24,14 @@ module Chronic
|
|
24
24
|
|
25
25
|
case pointer
|
26
26
|
when :future
|
27
|
-
day_begin =
|
28
|
-
day_end =
|
27
|
+
day_begin = Chronic.construct(@now.year, @now.month, @now.day, @now.hour)
|
28
|
+
day_end = Chronic.construct(@now.year, @now.month, @now.day) + DAY_SECONDS
|
29
29
|
when :past
|
30
|
-
day_begin =
|
31
|
-
day_end =
|
30
|
+
day_begin = Chronic.construct(@now.year, @now.month, @now.day)
|
31
|
+
day_end = Chronic.construct(@now.year, @now.month, @now.day, @now.hour)
|
32
32
|
when :none
|
33
|
-
day_begin =
|
34
|
-
day_end =
|
33
|
+
day_begin = Chronic.construct(@now.year, @now.month, @now.day)
|
34
|
+
day_end = Chronic.construct(@now.year, @now.month, @now.day) + DAY_SECONDS
|
35
35
|
end
|
36
36
|
|
37
37
|
Span.new(day_begin, day_end)
|
@@ -24,7 +24,7 @@ module Chronic
|
|
24
24
|
@current_date += direction * 7
|
25
25
|
end
|
26
26
|
next_date = @current_date.succ
|
27
|
-
Span.new(
|
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
28
|
end
|
29
29
|
|
30
30
|
def this(pointer = :future)
|
@@ -28,27 +28,27 @@ module Chronic
|
|
28
28
|
full_day = 60 * 60 * 24
|
29
29
|
|
30
30
|
if !@current_span
|
31
|
-
now_seconds = @now -
|
31
|
+
now_seconds = @now - Chronic.construct(@now.year, @now.month, @now.day)
|
32
32
|
if now_seconds < @range.begin
|
33
33
|
case pointer
|
34
34
|
when :future
|
35
|
-
range_start =
|
35
|
+
range_start = Chronic.construct(@now.year, @now.month, @now.day) + @range.begin
|
36
36
|
when :past
|
37
|
-
range_start =
|
37
|
+
range_start = Chronic.construct(@now.year, @now.month, @now.day) - full_day + @range.begin
|
38
38
|
end
|
39
39
|
elsif now_seconds > @range.end
|
40
40
|
case pointer
|
41
41
|
when :future
|
42
|
-
range_start =
|
42
|
+
range_start = Chronic.construct(@now.year, @now.month, @now.day) + full_day + @range.begin
|
43
43
|
when :past
|
44
|
-
range_start =
|
44
|
+
range_start = Chronic.construct(@now.year, @now.month, @now.day) + @range.begin
|
45
45
|
end
|
46
46
|
else
|
47
47
|
case pointer
|
48
48
|
when :future
|
49
|
-
range_start =
|
49
|
+
range_start = Chronic.construct(@now.year, @now.month, @now.day) + full_day + @range.begin
|
50
50
|
when :past
|
51
|
-
range_start =
|
51
|
+
range_start = Chronic.construct(@now.year, @now.month, @now.day) - full_day + @range.begin
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
@@ -66,7 +66,7 @@ module Chronic
|
|
66
66
|
def this(context = :future)
|
67
67
|
super
|
68
68
|
|
69
|
-
range_start =
|
69
|
+
range_start = Chronic.construct(@now.year, @now.month, @now.day) + @range.begin
|
70
70
|
@current_span = Span.new(range_start, range_start + (@range.end - @range.begin))
|
71
71
|
end
|
72
72
|
|
@@ -38,7 +38,7 @@ module Chronic
|
|
38
38
|
|
39
39
|
case pointer
|
40
40
|
when :future
|
41
|
-
this_fortnight_start =
|
41
|
+
this_fortnight_start = Chronic.construct(@now.year, @now.month, @now.day, @now.hour) + RepeaterHour::HOUR_SECONDS
|
42
42
|
sunday_repeater = RepeaterDayName.new(:sunday)
|
43
43
|
sunday_repeater.start = @now
|
44
44
|
sunday_repeater.this(:future)
|
@@ -46,7 +46,7 @@ module Chronic
|
|
46
46
|
this_fortnight_end = this_sunday_span.begin
|
47
47
|
Span.new(this_fortnight_start, this_fortnight_end)
|
48
48
|
when :past
|
49
|
-
this_fortnight_end =
|
49
|
+
this_fortnight_end = Chronic.construct(@now.year, @now.month, @now.day, @now.hour)
|
50
50
|
sunday_repeater = RepeaterDayName.new(:sunday)
|
51
51
|
sunday_repeater.start = @now
|
52
52
|
last_sunday_span = sunday_repeater.next(:past)
|
@@ -12,9 +12,9 @@ module Chronic
|
|
12
12
|
if !@current_hour_start
|
13
13
|
case pointer
|
14
14
|
when :future
|
15
|
-
@current_hour_start =
|
15
|
+
@current_hour_start = Chronic.construct(@now.year, @now.month, @now.day, @now.hour + 1)
|
16
16
|
when :past
|
17
|
-
@current_hour_start =
|
17
|
+
@current_hour_start = Chronic.construct(@now.year, @now.month, @now.day, @now.hour - 1)
|
18
18
|
end
|
19
19
|
else
|
20
20
|
direction = pointer == :future ? 1 : -1
|
@@ -29,13 +29,13 @@ module Chronic
|
|
29
29
|
|
30
30
|
case pointer
|
31
31
|
when :future
|
32
|
-
hour_start =
|
33
|
-
hour_end =
|
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)
|
34
34
|
when :past
|
35
|
-
hour_start =
|
36
|
-
hour_end =
|
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
37
|
when :none
|
38
|
-
hour_start =
|
38
|
+
hour_start = Chronic.construct(@now.year, @now.month, @now.day, @now.hour)
|
39
39
|
hour_end = hour_start + HOUR_SECONDS
|
40
40
|
end
|
41
41
|
|
@@ -12,9 +12,9 @@ module Chronic
|
|
12
12
|
if !@current_minute_start
|
13
13
|
case pointer
|
14
14
|
when :future
|
15
|
-
@current_minute_start =
|
15
|
+
@current_minute_start = Chronic.construct(@now.year, @now.month, @now.day, @now.hour, @now.min + 1)
|
16
16
|
when :past
|
17
|
-
@current_minute_start =
|
17
|
+
@current_minute_start = Chronic.construct(@now.year, @now.month, @now.day, @now.hour, @now.min - 1)
|
18
18
|
end
|
19
19
|
else
|
20
20
|
direction = pointer == :future ? 1 : -1
|
@@ -30,13 +30,13 @@ module Chronic
|
|
30
30
|
case pointer
|
31
31
|
when :future
|
32
32
|
minute_begin = @now
|
33
|
-
minute_end =
|
33
|
+
minute_end = Chronic.construct(@now.year, @now.month, @now.day, @now.hour, @now.min)
|
34
34
|
when :past
|
35
|
-
minute_begin =
|
35
|
+
minute_begin = Chronic.construct(@now.year, @now.month, @now.day, @now.hour, @now.min)
|
36
36
|
minute_end = @now
|
37
37
|
when :none
|
38
|
-
minute_begin =
|
39
|
-
minute_end =
|
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
40
|
end
|
41
41
|
|
42
42
|
Span.new(minute_begin, minute_end)
|
@@ -13,12 +13,12 @@ module Chronic
|
|
13
13
|
super
|
14
14
|
|
15
15
|
if !@current_month_start
|
16
|
-
@current_month_start = offset_by(
|
16
|
+
@current_month_start = offset_by(Chronic.construct(@now.year, @now.month), 1, pointer)
|
17
17
|
else
|
18
|
-
@current_month_start = offset_by(
|
18
|
+
@current_month_start = offset_by(Chronic.construct(@current_month_start.year, @current_month_start.month), 1, pointer)
|
19
19
|
end
|
20
20
|
|
21
|
-
Span.new(@current_month_start,
|
21
|
+
Span.new(@current_month_start, Chronic.construct(@current_month_start.year, @current_month_start.month + 1))
|
22
22
|
end
|
23
23
|
|
24
24
|
def this(pointer = :future)
|
@@ -26,14 +26,14 @@ module Chronic
|
|
26
26
|
|
27
27
|
case pointer
|
28
28
|
when :future
|
29
|
-
month_start =
|
30
|
-
month_end = self.offset_by(
|
29
|
+
month_start = Chronic.construct(@now.year, @now.month, @now.day + 1)
|
30
|
+
month_end = self.offset_by(Chronic.construct(@now.year, @now.month), 1, :future)
|
31
31
|
when :past
|
32
|
-
month_start =
|
33
|
-
month_end =
|
32
|
+
month_start = Chronic.construct(@now.year, @now.month)
|
33
|
+
month_end = Chronic.construct(@now.year, @now.month, @now.day)
|
34
34
|
when :none
|
35
|
-
month_start =
|
36
|
-
month_end = self.offset_by(
|
35
|
+
month_start = Chronic.construct(@now.year, @now.month)
|
36
|
+
month_end = self.offset_by(Chronic.construct(@now.year, @now.month), 1, :future)
|
37
37
|
end
|
38
38
|
|
39
39
|
Span.new(month_start, month_end)
|
@@ -59,7 +59,7 @@ module Chronic
|
|
59
59
|
days = month_days(new_year, new_month)
|
60
60
|
new_day = time.day > days ? days : time.day
|
61
61
|
|
62
|
-
|
62
|
+
Chronic.construct(new_year, new_month, new_day, time.hour, time.min, time.sec)
|
63
63
|
end
|
64
64
|
|
65
65
|
def width
|
@@ -27,30 +27,30 @@ module Chronic
|
|
27
27
|
case pointer
|
28
28
|
when :future
|
29
29
|
if @now.month < index
|
30
|
-
@current_month_begin =
|
30
|
+
@current_month_begin = Chronic.construct(@now.year, index)
|
31
31
|
elsif @now.month > index
|
32
|
-
@current_month_begin =
|
32
|
+
@current_month_begin = Chronic.construct(@now.year + 1, index)
|
33
33
|
end
|
34
34
|
when :none
|
35
35
|
if @now.month <= index
|
36
|
-
@current_month_begin =
|
36
|
+
@current_month_begin = Chronic.construct(@now.year, index)
|
37
37
|
elsif @now.month > index
|
38
|
-
@current_month_begin =
|
38
|
+
@current_month_begin = Chronic.construct(@now.year + 1, index)
|
39
39
|
end
|
40
40
|
when :past
|
41
41
|
if @now.month >= index
|
42
|
-
@current_month_begin =
|
42
|
+
@current_month_begin = Chronic.construct(@now.year, index)
|
43
43
|
elsif @now.month < index
|
44
|
-
@current_month_begin =
|
44
|
+
@current_month_begin = Chronic.construct(@now.year - 1, index)
|
45
45
|
end
|
46
46
|
end
|
47
47
|
@current_month_begin || raise("Current month should be set by now")
|
48
48
|
else
|
49
49
|
case pointer
|
50
50
|
when :future
|
51
|
-
@current_month_begin =
|
51
|
+
@current_month_begin = Chronic.construct(@current_month_begin.year + 1, @current_month_begin.month)
|
52
52
|
when :past
|
53
|
-
@current_month_begin =
|
53
|
+
@current_month_begin = Chronic.construct(@current_month_begin.year - 1, @current_month_begin.month)
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
@@ -65,7 +65,7 @@ module Chronic
|
|
65
65
|
next_month_month = cur_month_month + 1
|
66
66
|
end
|
67
67
|
|
68
|
-
Span.new(@current_month_begin,
|
68
|
+
Span.new(@current_month_begin, Chronic.construct(next_month_year, next_month_month))
|
69
69
|
end
|
70
70
|
|
71
71
|
def this(pointer = :future)
|
@@ -16,7 +16,7 @@ module Chronic
|
|
16
16
|
super
|
17
17
|
|
18
18
|
direction = pointer == :future ? 1 : -1
|
19
|
-
next_season = Season.find_next_season(find_current_season(@now
|
19
|
+
next_season = Season.find_next_season(find_current_season(MiniDate.from_time(@now)), direction)
|
20
20
|
|
21
21
|
find_next_season_span(direction, next_season)
|
22
22
|
end
|
@@ -26,8 +26,8 @@ module Chronic
|
|
26
26
|
|
27
27
|
direction = pointer == :future ? 1 : -1
|
28
28
|
|
29
|
-
today =
|
30
|
-
this_ssn = find_current_season(@now
|
29
|
+
today = Chronic.construct(@now.year, @now.month, @now.day)
|
30
|
+
this_ssn = find_current_season(MiniDate.from_time(@now))
|
31
31
|
case pointer
|
32
32
|
when :past
|
33
33
|
this_ssn_start = today + direction * num_seconds_til_start(this_ssn, direction)
|
@@ -63,9 +63,9 @@ module Chronic
|
|
63
63
|
private
|
64
64
|
|
65
65
|
def find_next_season_span(direction, next_season)
|
66
|
-
|
67
|
-
@next_season_start =
|
68
|
-
@next_season_end =
|
66
|
+
unless @next_season_start or @next_season_end
|
67
|
+
@next_season_start = Chronic.construct(@now.year, @now.month, @now.day)
|
68
|
+
@next_season_end = Chronic.construct(@now.year, @now.month, @now.day)
|
69
69
|
end
|
70
70
|
|
71
71
|
@next_season_start += direction * num_seconds_til_start(next_season, direction)
|
@@ -81,10 +81,10 @@ module Chronic
|
|
81
81
|
end
|
82
82
|
|
83
83
|
def num_seconds_til(goal, direction)
|
84
|
-
start =
|
84
|
+
start = Chronic.construct(@now.year, @now.month, @now.day)
|
85
85
|
seconds = 0
|
86
86
|
|
87
|
-
until (start + direction * seconds).
|
87
|
+
until MiniDate.from_time(start + direction * seconds).equals?(goal)
|
88
88
|
seconds += RepeaterDay::DAY_SECONDS
|
89
89
|
end
|
90
90
|
|
@@ -101,8 +101,8 @@ module Chronic
|
|
101
101
|
|
102
102
|
def construct_season(start, finish)
|
103
103
|
Span.new(
|
104
|
-
|
105
|
-
|
104
|
+
Chronic.construct(start.year, start.month, start.day),
|
105
|
+
Chronic.construct(finish.year, finish.month, finish.day)
|
106
106
|
)
|
107
107
|
end
|
108
108
|
end
|
@@ -11,10 +11,10 @@ module Chronic
|
|
11
11
|
def this(pointer = :future)
|
12
12
|
direction = pointer == :future ? 1 : -1
|
13
13
|
|
14
|
-
today =
|
14
|
+
today = Chronic.construct(@now.year, @now.month, @now.day)
|
15
15
|
goal_ssn_start = today + direction * num_seconds_til_start(@type, direction)
|
16
16
|
goal_ssn_end = today + direction * num_seconds_til_end(@type, direction)
|
17
|
-
curr_ssn = find_current_season(@now
|
17
|
+
curr_ssn = find_current_season(MiniDate.from_time(@now))
|
18
18
|
case pointer
|
19
19
|
when :past
|
20
20
|
this_ssn_start = goal_ssn_start
|
@@ -21,7 +21,7 @@ module Chronic
|
|
21
21
|
direction = pointer == :future ? 1 : -1
|
22
22
|
|
23
23
|
if !@current_weekday_start
|
24
|
-
@current_weekday_start =
|
24
|
+
@current_weekday_start = Chronic.construct(@now.year, @now.month, @now.day)
|
25
25
|
@current_weekday_start += direction * DAY_SECONDS
|
26
26
|
|
27
27
|
until is_weekday?(@current_weekday_start.wday)
|
@@ -12,16 +12,16 @@ module Chronic
|
|
12
12
|
if !@current_year_start
|
13
13
|
case pointer
|
14
14
|
when :future
|
15
|
-
@current_year_start =
|
15
|
+
@current_year_start = Chronic.construct(@now.year + 1)
|
16
16
|
when :past
|
17
|
-
@current_year_start =
|
17
|
+
@current_year_start = Chronic.construct(@now.year - 1)
|
18
18
|
end
|
19
19
|
else
|
20
20
|
diff = pointer == :future ? 1 : -1
|
21
|
-
@current_year_start =
|
21
|
+
@current_year_start = Chronic.construct(@current_year_start.year + diff)
|
22
22
|
end
|
23
23
|
|
24
|
-
Span.new(@current_year_start,
|
24
|
+
Span.new(@current_year_start, Chronic.construct(@current_year_start.year + 1))
|
25
25
|
end
|
26
26
|
|
27
27
|
def this(pointer = :future)
|
@@ -29,14 +29,14 @@ module Chronic
|
|
29
29
|
|
30
30
|
case pointer
|
31
31
|
when :future
|
32
|
-
this_year_start =
|
33
|
-
this_year_end =
|
32
|
+
this_year_start = Chronic.construct(@now.year, @now.month, @now.day) + RepeaterDay::DAY_SECONDS
|
33
|
+
this_year_end = Chronic.construct(@now.year + 1, 1, 1)
|
34
34
|
when :past
|
35
|
-
this_year_start =
|
36
|
-
this_year_end =
|
35
|
+
this_year_start = Chronic.construct(@now.year, 1, 1)
|
36
|
+
this_year_end = Chronic.construct(@now.year, @now.month, @now.day)
|
37
37
|
when :none
|
38
|
-
this_year_start =
|
39
|
-
this_year_end =
|
38
|
+
this_year_start = Chronic.construct(@now.year, 1, 1)
|
39
|
+
this_year_end = Chronic.construct(@now.year + 1, 1, 1)
|
40
40
|
end
|
41
41
|
|
42
42
|
Span.new(this_year_start, this_year_end)
|
@@ -63,7 +63,7 @@ module Chronic
|
|
63
63
|
year = time.year + (amount * direction)
|
64
64
|
days = month_days(year, time.month)
|
65
65
|
day = time.day > days ? days : time.day
|
66
|
-
|
66
|
+
Chronic.construct(year, time.month, day, time.hour, time.min, time.sec)
|
67
67
|
end
|
68
68
|
|
69
69
|
def month_days(year, month)
|