ice_cube 0.16.1 → 0.16.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/config/locales/en.yml +7 -46
- data/config/locales/es.yml +47 -83
- data/config/locales/ja.yml +52 -29
- data/lib/ice_cube/rules/weekly_rule.rb +2 -2
- data/lib/ice_cube/schedule.rb +7 -20
- data/lib/ice_cube/time_util.rb +34 -33
- data/lib/ice_cube/validated_rule.rb +4 -4
- data/lib/ice_cube/validations/day_of_week.rb +1 -1
- data/lib/ice_cube/validations/month_of_year.rb +1 -1
- data/lib/ice_cube/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 51dd94d70b0d51847c678abf736d395ddbee5e2e
|
4
|
+
data.tar.gz: 2b69372e7e4e67487347cab5a8a773da40a87e91
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d20e08c68105003f8a6c3f192c679d185c07e43681543844f890d00947d94d6c42d5e82a350e83cab506c74183bbd42eef2cb8d5deeab8f7979a819884221dff
|
7
|
+
data.tar.gz: f1ab8c1b534dd70e185da9b272a973202cb071f29bd90cb2a31fa7d83d1b3f0e61c321d3d402e79e0059cf698374a0465dc954218de77afe0ac459cc0f990f47
|
data/config/locales/en.yml
CHANGED
@@ -6,28 +6,6 @@ en:
|
|
6
6
|
date:
|
7
7
|
formats:
|
8
8
|
default: '%B %-d, %Y'
|
9
|
-
month_names:
|
10
|
-
-
|
11
|
-
- January
|
12
|
-
- February
|
13
|
-
- March
|
14
|
-
- April
|
15
|
-
- May
|
16
|
-
- June
|
17
|
-
- July
|
18
|
-
- August
|
19
|
-
- September
|
20
|
-
- October
|
21
|
-
- November
|
22
|
-
- December
|
23
|
-
day_names:
|
24
|
-
- Sunday
|
25
|
-
- Monday
|
26
|
-
- Tuesday
|
27
|
-
- Wednesday
|
28
|
-
- Thursday
|
29
|
-
- Friday
|
30
|
-
- Saturday
|
31
9
|
times:
|
32
10
|
other: '%{count} times'
|
33
11
|
one: '%{count} time'
|
@@ -91,13 +69,13 @@ en:
|
|
91
69
|
on_weekends: on Weekends
|
92
70
|
on_weekdays: on Weekdays
|
93
71
|
days_on:
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
72
|
+
- Sundays
|
73
|
+
- Mondays
|
74
|
+
- Tuesdays
|
75
|
+
- Wednesdays
|
76
|
+
- Thursdays
|
77
|
+
- Fridays
|
78
|
+
- Saturdays
|
101
79
|
on_days: on %{days}
|
102
80
|
array:
|
103
81
|
last_word_connector: ', and '
|
@@ -114,7 +92,6 @@ en:
|
|
114
92
|
until: '%{rest} %{current}'
|
115
93
|
count: '%{rest} %{current}'
|
116
94
|
default: '%{rest} %{current}'
|
117
|
-
|
118
95
|
date:
|
119
96
|
abbr_day_names:
|
120
97
|
- Sun
|
@@ -146,10 +123,6 @@ en:
|
|
146
123
|
- Thursday
|
147
124
|
- Friday
|
148
125
|
- Saturday
|
149
|
-
formats:
|
150
|
-
default: "%Y-%m-%d"
|
151
|
-
long: "%B %d, %Y"
|
152
|
-
short: "%b %d"
|
153
126
|
month_names:
|
154
127
|
-
|
155
128
|
- January
|
@@ -164,15 +137,3 @@ en:
|
|
164
137
|
- October
|
165
138
|
- November
|
166
139
|
- December
|
167
|
-
order:
|
168
|
-
- :year
|
169
|
-
- :month
|
170
|
-
- :day
|
171
|
-
|
172
|
-
time:
|
173
|
-
am: am
|
174
|
-
formats:
|
175
|
-
default: "%a, %d %b %Y %H:%M:%S %z"
|
176
|
-
long: "%B %d, %Y %H:%M"
|
177
|
-
short: "%d %b %H:%M"
|
178
|
-
pm: pm
|
data/config/locales/es.yml
CHANGED
@@ -6,28 +6,6 @@ es:
|
|
6
6
|
date:
|
7
7
|
formats:
|
8
8
|
default: '%-d de %B de %Y'
|
9
|
-
month_names:
|
10
|
-
-
|
11
|
-
- Enero
|
12
|
-
- Febrero
|
13
|
-
- Marzo
|
14
|
-
- Abril
|
15
|
-
- Mayo
|
16
|
-
- Junio
|
17
|
-
- Julio
|
18
|
-
- Agosto
|
19
|
-
- Septiembre
|
20
|
-
- Octubre
|
21
|
-
- Noviembre
|
22
|
-
- Diciembre
|
23
|
-
day_names:
|
24
|
-
- Domingo
|
25
|
-
- Lunes
|
26
|
-
- Martes
|
27
|
-
- Miércoles
|
28
|
-
- Jueves
|
29
|
-
- Viernes
|
30
|
-
- Sábado
|
31
9
|
times:
|
32
10
|
other: '%{count} veces'
|
33
11
|
one: '%{count} vez'
|
@@ -92,13 +70,13 @@ es:
|
|
92
70
|
on_weekends: en fin de semana
|
93
71
|
on_weekdays: en días laborables
|
94
72
|
days_on:
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
73
|
+
- los domingos
|
74
|
+
- los lunes
|
75
|
+
- los martes
|
76
|
+
- los miércoles
|
77
|
+
- los jueves
|
78
|
+
- los viernes
|
79
|
+
- los sábados
|
102
80
|
on_days: '%{days}'
|
103
81
|
array:
|
104
82
|
last_word_connector: ' y '
|
@@ -115,62 +93,48 @@ es:
|
|
115
93
|
until: '%{rest} %{current}'
|
116
94
|
count: '%{rest} %{current}'
|
117
95
|
default: '%{rest} %{current}'
|
118
|
-
|
119
96
|
date:
|
120
97
|
day_names:
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
98
|
+
- Domingo
|
99
|
+
- Lunes
|
100
|
+
- Martes
|
101
|
+
- Miércoles
|
102
|
+
- Jueves
|
103
|
+
- Viernes
|
104
|
+
- Sábado
|
128
105
|
abbr_day_names:
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
# Don't forget the nil at the beginning; there's no such thing as a 0th month
|
106
|
+
- Dom
|
107
|
+
- Lun
|
108
|
+
- Mar
|
109
|
+
- Mie
|
110
|
+
- Jue
|
111
|
+
- Vie
|
112
|
+
- Sab
|
137
113
|
month_names:
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
114
|
+
-
|
115
|
+
- Enero
|
116
|
+
- Febrero
|
117
|
+
- Marzo
|
118
|
+
- Abril
|
119
|
+
- Mayo
|
120
|
+
- Junio
|
121
|
+
- Julio
|
122
|
+
- Agosto
|
123
|
+
- Septiembre
|
124
|
+
- Octubre
|
125
|
+
- Noviembre
|
126
|
+
- Diciembre
|
151
127
|
abbr_month_names:
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
formats:
|
166
|
-
default: '%d/%m/%Y'
|
167
|
-
long: '%d de %B de %Y'
|
168
|
-
short: '%d de %B'
|
169
|
-
|
170
|
-
time:
|
171
|
-
formats:
|
172
|
-
default: "%A, %d de %B de %Y %H:%M:%S %z"
|
173
|
-
short: "%d de %b %H:%M"
|
174
|
-
long: "%d de %B de %Y a las %H:%M"
|
175
|
-
am: "am"
|
176
|
-
pm: "pm"
|
128
|
+
-
|
129
|
+
- Ene
|
130
|
+
- Feb
|
131
|
+
- Mar
|
132
|
+
- Abr
|
133
|
+
- May
|
134
|
+
- Jun
|
135
|
+
- Jul
|
136
|
+
- Ago
|
137
|
+
- Sep
|
138
|
+
- Oct
|
139
|
+
- Nov
|
140
|
+
- Dic
|
data/config/locales/ja.yml
CHANGED
@@ -6,28 +6,6 @@ ja:
|
|
6
6
|
date:
|
7
7
|
formats:
|
8
8
|
default: '%Y年%m月%d日'
|
9
|
-
month_names:
|
10
|
-
-
|
11
|
-
- 1月
|
12
|
-
- 2月
|
13
|
-
- 3月
|
14
|
-
- 4月
|
15
|
-
- 5月
|
16
|
-
- 6月
|
17
|
-
- 7月
|
18
|
-
- 8月
|
19
|
-
- 9月
|
20
|
-
- 10月
|
21
|
-
- 11月
|
22
|
-
- 12月
|
23
|
-
day_names:
|
24
|
-
- 日曜
|
25
|
-
- 月曜
|
26
|
-
- 火曜
|
27
|
-
- 水曜
|
28
|
-
- 木曜
|
29
|
-
- 金曜
|
30
|
-
- 土曜
|
31
9
|
times:
|
32
10
|
other: '%{count}回'
|
33
11
|
one: '%{count}回'
|
@@ -82,13 +60,13 @@ ja:
|
|
82
60
|
on_weekends: 週末
|
83
61
|
on_weekdays: 平日
|
84
62
|
days_on:
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
63
|
+
- 日曜
|
64
|
+
- 月曜
|
65
|
+
- 火曜
|
66
|
+
- 水曜
|
67
|
+
- 木曜
|
68
|
+
- 金曜
|
69
|
+
- 土曜
|
92
70
|
on_days: '%{days}'
|
93
71
|
array:
|
94
72
|
last_word_connector: '、'
|
@@ -105,3 +83,48 @@ ja:
|
|
105
83
|
until: '%{current}%{rest}'
|
106
84
|
count: '%{rest}%{current}'
|
107
85
|
default: '%{rest}%{current}'
|
86
|
+
date:
|
87
|
+
abbr_day_names:
|
88
|
+
- 日
|
89
|
+
- 月
|
90
|
+
- 火
|
91
|
+
- 水
|
92
|
+
- 木
|
93
|
+
- 金
|
94
|
+
- 土
|
95
|
+
abbr_month_names:
|
96
|
+
-
|
97
|
+
- 1月
|
98
|
+
- 2月
|
99
|
+
- 3月
|
100
|
+
- 4月
|
101
|
+
- 5月
|
102
|
+
- 6月
|
103
|
+
- 7月
|
104
|
+
- 8月
|
105
|
+
- 9月
|
106
|
+
- 10月
|
107
|
+
- 11月
|
108
|
+
- 12月
|
109
|
+
day_names:
|
110
|
+
- 日曜
|
111
|
+
- 月曜
|
112
|
+
- 火曜
|
113
|
+
- 水曜
|
114
|
+
- 木曜
|
115
|
+
- 金曜
|
116
|
+
- 土曜
|
117
|
+
month_names:
|
118
|
+
-
|
119
|
+
- 1月
|
120
|
+
- 2月
|
121
|
+
- 3月
|
122
|
+
- 4月
|
123
|
+
- 5月
|
124
|
+
- 6月
|
125
|
+
- 7月
|
126
|
+
- 8月
|
127
|
+
- 9月
|
128
|
+
- 10月
|
129
|
+
- 11月
|
130
|
+
- 12月
|
@@ -41,9 +41,9 @@ module IceCube
|
|
41
41
|
wday_validations = other_interval_validations.select { |v| v.type == :wday }
|
42
42
|
return 0 if wday_validations.none?
|
43
43
|
|
44
|
-
days =
|
44
|
+
days = step_time.to_date - start_time.to_date
|
45
45
|
interval = base_interval_validation.validate(step_time, start_time).to_i
|
46
|
-
min_wday = TimeUtil.normalize_wday(
|
46
|
+
min_wday = wday_validations.map { |v| TimeUtil.normalize_wday(v.day, week_start) }.min
|
47
47
|
step_wday = TimeUtil.normalize_wday(step_time.wday, week_start)
|
48
48
|
|
49
49
|
days + interval - step_wday + min_wday
|
data/lib/ice_cube/schedule.rb
CHANGED
@@ -420,7 +420,7 @@ module IceCube
|
|
420
420
|
# Find all of the occurrences for the schedule between opening_time
|
421
421
|
# and closing_time
|
422
422
|
# Iteration is unrolled in pairs to skip duplicate times in end of DST
|
423
|
-
def enumerate_occurrences(opening_time, closing_time = nil, options = {}
|
423
|
+
def enumerate_occurrences(opening_time, closing_time = nil, options = {})
|
424
424
|
opening_time = TimeUtil.match_zone(opening_time, start_time)
|
425
425
|
closing_time = TimeUtil.match_zone(closing_time, start_time)
|
426
426
|
opening_time += start_time.subsec - opening_time.subsec rescue 0
|
@@ -428,23 +428,16 @@ module IceCube
|
|
428
428
|
spans = options[:spans] == true && duration != 0
|
429
429
|
Enumerator.new do |yielder|
|
430
430
|
reset
|
431
|
-
t1 = full_required? ? start_time : opening_time
|
431
|
+
t1 = full_required? ? start_time : opening_time
|
432
|
+
t1 -= duration if spans
|
433
|
+
t1 = start_time if t1 < start_time
|
432
434
|
loop do
|
433
435
|
break unless (t0 = next_time(t1, closing_time))
|
434
436
|
break if closing_time && t0 > closing_time
|
435
437
|
if (spans ? (t0.end_time > opening_time) : (t0 >= opening_time))
|
436
|
-
yielder << (block_given? ?
|
438
|
+
yielder << (block_given? ? yield(t0) : t0)
|
437
439
|
end
|
438
|
-
|
439
|
-
break if closing_time && t1 > closing_time
|
440
|
-
if TimeUtil.same_clock?(t0, t1) && recurrence_rules.any?(&:dst_adjust?)
|
441
|
-
wind_back_dst
|
442
|
-
next (t1 += 1)
|
443
|
-
end
|
444
|
-
if (spans ? (t1.end_time > opening_time) : (t1 >= opening_time))
|
445
|
-
yielder << (block_given? ? block.call(t1) : t1)
|
446
|
-
end
|
447
|
-
next (t1 += 1)
|
440
|
+
t1 = t0 + 1
|
448
441
|
end
|
449
442
|
end
|
450
443
|
end
|
@@ -460,7 +453,7 @@ module IceCube
|
|
460
453
|
min_time
|
461
454
|
end
|
462
455
|
end
|
463
|
-
break
|
456
|
+
break unless min_time
|
464
457
|
next (time = min_time + 1) if exception_time?(min_time)
|
465
458
|
break Occurrence.new(min_time, min_time + duration)
|
466
459
|
end
|
@@ -511,12 +504,6 @@ module IceCube
|
|
511
504
|
end
|
512
505
|
end
|
513
506
|
|
514
|
-
def wind_back_dst
|
515
|
-
recurrence_rules.each do |rule|
|
516
|
-
rule.skipped_for_dst
|
517
|
-
end
|
518
|
-
end
|
519
|
-
|
520
507
|
end
|
521
508
|
|
522
509
|
end
|
data/lib/ice_cube/time_util.rb
CHANGED
@@ -47,7 +47,7 @@ module IceCube
|
|
47
47
|
time.in_time_zone(reference.time_zone)
|
48
48
|
else
|
49
49
|
if reference.utc?
|
50
|
-
time.
|
50
|
+
time.getgm
|
51
51
|
elsif reference.zone
|
52
52
|
time.getlocal
|
53
53
|
else
|
@@ -89,18 +89,27 @@ module IceCube
|
|
89
89
|
|
90
90
|
# Serialize a time appropriate for storing
|
91
91
|
def self.serialize_time(time)
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
92
|
+
case time
|
93
|
+
when Time, Date
|
94
|
+
if time.respond_to?(:time_zone)
|
95
|
+
{:time => time.utc, :zone => time.time_zone.name}
|
96
|
+
else
|
97
|
+
time
|
98
|
+
end
|
99
|
+
when DateTime
|
100
|
+
Time.local(time.year, time.month, time.day, time.hour, time.min, time.sec)
|
101
|
+
else
|
102
|
+
raise ArgumentError, "cannot serialize #{time.inspect}, expected a Time"
|
96
103
|
end
|
97
104
|
end
|
98
105
|
|
99
106
|
# Deserialize a time serialized with serialize_time or in ISO8601 string format
|
100
107
|
def self.deserialize_time(time_or_hash)
|
101
108
|
case time_or_hash
|
102
|
-
when Time
|
109
|
+
when Time, Date
|
103
110
|
time_or_hash
|
111
|
+
when DateTime
|
112
|
+
Time.local(time.year, time.month, time.day, time.hour, time.min, time.sec)
|
104
113
|
when Hash
|
105
114
|
hash = FlexibleHash.new(time_or_hash)
|
106
115
|
hash[:time].in_time_zone(hash[:zone])
|
@@ -260,27 +269,32 @@ module IceCube
|
|
260
269
|
|
261
270
|
def initialize(time, dst_adjust = true)
|
262
271
|
@dst_adjust = dst_adjust
|
263
|
-
@
|
272
|
+
@base = time
|
273
|
+
if dst_adjust
|
274
|
+
@time = Time.utc(time.year, time.month, time.day, time.hour, time.min, time.sec + time.subsec)
|
275
|
+
else
|
276
|
+
@time = time
|
277
|
+
end
|
264
278
|
end
|
265
279
|
|
266
|
-
# Get the
|
280
|
+
# Get the wrapped time back in its original zone & format
|
267
281
|
def to_time
|
268
|
-
@time
|
282
|
+
return @time unless @dst_adjust
|
283
|
+
parts = @time.year, @time.month, @time.day, @time.hour, @time.min, @time.sec + @time.subsec
|
284
|
+
TimeUtil.build_in_zone(parts, @base)
|
269
285
|
end
|
270
286
|
|
271
287
|
# DST-safely add an interval of time to the wrapped time
|
272
288
|
def add(type, val)
|
273
289
|
type = :day if type == :wday
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
end
|
283
|
-
end
|
290
|
+
@time += case type
|
291
|
+
when :year then TimeUtil.days_in_n_years(@time, val) * ONE_DAY
|
292
|
+
when :month then TimeUtil.days_in_n_months(@time, val) * ONE_DAY
|
293
|
+
when :day then val * ONE_DAY
|
294
|
+
when :hour then val * ONE_HOUR
|
295
|
+
when :min then val * ONE_MINUTE
|
296
|
+
when :sec then val
|
297
|
+
end
|
284
298
|
end
|
285
299
|
|
286
300
|
# Clear everything below a certain type
|
@@ -289,25 +303,12 @@ module IceCube
|
|
289
303
|
type = :day if type == :wday
|
290
304
|
CLEAR_ORDER.each do |ptype|
|
291
305
|
break if ptype == type
|
292
|
-
|
293
|
-
send(:"clear_#{ptype}")
|
294
|
-
end
|
306
|
+
send :"clear_#{ptype}"
|
295
307
|
end
|
296
308
|
end
|
297
309
|
|
298
310
|
private
|
299
311
|
|
300
|
-
def adjust(&block)
|
301
|
-
if @dst_adjust
|
302
|
-
off = @time.utc_offset
|
303
|
-
yield
|
304
|
-
diff = off - @time.utc_offset
|
305
|
-
@time += diff if diff != 0
|
306
|
-
else
|
307
|
-
yield
|
308
|
-
end
|
309
|
-
end
|
310
|
-
|
311
312
|
def clear_sec
|
312
313
|
@time.sec > 0 ? @time -= @time.sec : @time
|
313
314
|
end
|
@@ -79,12 +79,12 @@ module IceCube
|
|
79
79
|
end
|
80
80
|
|
81
81
|
def dst_adjust?
|
82
|
-
@validations[:interval].any?
|
82
|
+
@validations[:interval].any?(&:dst_adjust?)
|
83
83
|
end
|
84
84
|
|
85
85
|
def to_s
|
86
86
|
builder = StringBuilder.new
|
87
|
-
@validations.
|
87
|
+
@validations.each_value do |validations|
|
88
88
|
validations.each do |validation|
|
89
89
|
validation.build_s(builder)
|
90
90
|
end
|
@@ -94,7 +94,7 @@ module IceCube
|
|
94
94
|
|
95
95
|
def to_hash
|
96
96
|
builder = HashBuilder.new(self)
|
97
|
-
@validations.
|
97
|
+
@validations.each_value do |validations|
|
98
98
|
validations.each do |validation|
|
99
99
|
validation.build_hash(builder)
|
100
100
|
end
|
@@ -104,7 +104,7 @@ module IceCube
|
|
104
104
|
|
105
105
|
def to_ical
|
106
106
|
builder = IcalBuilder.new
|
107
|
-
@validations.
|
107
|
+
@validations.each_value do |validations|
|
108
108
|
validations.each do |validation|
|
109
109
|
validation.build_ical(builder)
|
110
110
|
end
|
data/lib/ice_cube/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ice_cube
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.16.
|
4
|
+
version: 0.16.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Crepezzi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-07-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -121,7 +121,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
121
121
|
version: '0'
|
122
122
|
requirements: []
|
123
123
|
rubyforge_project: ice-cube
|
124
|
-
rubygems_version: 2.
|
124
|
+
rubygems_version: 2.6.11
|
125
125
|
signing_key:
|
126
126
|
specification_version: 4
|
127
127
|
summary: Ruby Date Recurrence Library
|