fugit 1.11.2 → 1.12.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/CREDITS.md +1 -0
- data/README.md +93 -10
- data/fugit.gemspec +1 -1
- data/lib/fugit/cron.rb +14 -18
- data/lib/fugit.rb +1 -1
- metadata +4 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 31f13ce15ee0d51e6029539634fd55e14401f60ba03cdc6ad90c8e47bd4b711e
|
4
|
+
data.tar.gz: 91db0bb6fd6aa714e44e4c6d2b67fdbffc70495da77bf9946cda8d859bdf510a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 604a819a90770a746f33f2d93cdab4524f036a71ac901d311fb74c438f20eaa01a4fb13187f5eca96b7a449354d7864ef3b515674088b3bc60b36710afd8c9df
|
7
|
+
data.tar.gz: c83c544fa51e1a3e8bc2f76ff163276caa61a93927db6bbfe47642d91ffa85281c8522e1b36a2e9c988c85963c34edc86b47fab98dc1ee516a4495df63839ac8
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,13 @@
|
|
2
2
|
# CHANGELOG.md
|
3
3
|
|
4
4
|
|
5
|
+
## fugit 1.12.0 released 2025-09-30
|
6
|
+
|
7
|
+
* Upgrade et-orbi to ~> 1.4.0 for EtOrbi.rweek_ref=, gh-114
|
8
|
+
this changes the rweek reference point to 2018-12-31 (Monday)
|
9
|
+
* Fix `12 0 * * wed%4+1,wed%4` issue where 1 wed was ignored, gh-114
|
10
|
+
|
11
|
+
|
5
12
|
## fugit 1.11.2 released 2025-08-22
|
6
13
|
|
7
14
|
* Fix "every day at midnight America/Los_Angeles", gh-113, Mark R. James
|
data/CREDITS.md
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
|
2
2
|
# fugit credits
|
3
3
|
|
4
|
+
* Hugh Kelsey https://github.com/hughkelsey gh-94 rweek/rday / wed%4+1,wed%4
|
4
5
|
* Mark R. James, https://github.com/mrj, AM vs America/Los_Angeles, gh-113
|
5
6
|
* Tejas Bubane, https://github.com/tejasbubane, r3.4 in test matrix, gh-109
|
6
7
|
* Luis Castillo, https://github.com/lekastillo, nice_hash gh-108
|
data/README.md
CHANGED
@@ -296,7 +296,7 @@ The hash extension can only be used in the day-of-week field.
|
|
296
296
|
|
297
297
|
### the modulo extension
|
298
298
|
|
299
|
-
Fugit, since 1.1.10, also understands cron strings like
|
299
|
+
Fugit, since 1.1.10, also understands cron strings like `9 0 * * sun%2` which can be read as "every other Sunday at 9am" or `12 0 * * mon%4` for "every fourth monday at noon".
|
300
300
|
|
301
301
|
The modulo extension can only be used in the day-of-week field.
|
302
302
|
|
@@ -306,34 +306,117 @@ It can be combined, as in `9 0 * * sun%2,tue%3+2`
|
|
306
306
|
|
307
307
|
But what does it reference to? It starts at 1 on 2019-01-01 (in the EtOrbi instance timezone, not the UTC "timezone").
|
308
308
|
|
309
|
+
Since [et-orbi](https://github.com/floraison/et-orbi) 1.4.0, the reference has been switched to make `Monday 2018-12-31` as the reference, so that weeks start on Monday (read a bit below on how to make it start on another day).
|
310
|
+
|
309
311
|
```ruby
|
310
|
-
require 'et-orbi' # >= 1.1.8
|
312
|
+
require 'et-orbi' # >= 1.1.8 and < 1.4.0
|
313
|
+
|
314
|
+
class EtOrbi::EoTime
|
315
|
+
def d # debug
|
316
|
+
"%14s | rday: %4d | rweek: %3d" % [ strftime('%a'), rday, rweek ]
|
317
|
+
end
|
318
|
+
end
|
311
319
|
|
312
320
|
# the reference
|
313
|
-
|
314
|
-
p EtOrbi.parse('2019-01-01').rweek # => 1
|
321
|
+
puts EtOrbi.parse('2019-01-01').d # => Tue | rday: 1 | rweek: 1
|
315
322
|
p EtOrbi.parse('2019-01-01').rweek % 2 # => 1
|
316
323
|
|
317
324
|
# today (as of this coding...)
|
318
|
-
|
319
|
-
p EtOrbi.parse('2019-04-11').rweek # => 15
|
325
|
+
puts EtOrbi.parse('2019-04-11').d # => Thu | rday: 101 | rweek: 15
|
320
326
|
p EtOrbi.parse('2019-04-11').rweek % 2 # => 1
|
321
327
|
|
322
328
|
c = Fugit.parse('* * * * tue%2')
|
323
|
-
c.match?('2019-01-01') # => false, since rweek % 2 == 1
|
324
|
-
c.match?('2019-01-08') # => true, since rweek % 2 == 0
|
329
|
+
p c.match?('2019-01-01') # => false, since rweek % 2 == 1
|
330
|
+
p c.match?('2019-01-08') # => true, since rweek % 2 == 0
|
325
331
|
|
326
332
|
c = Fugit.parse('* * * * tue%2+1')
|
327
|
-
c.match?('2019-01-01') # => true, since (rweek + 1) % 2 == 0
|
328
|
-
c.match?('2019-01-08') # => false, since (rweek + 1) % 2 == 1
|
333
|
+
p c.match?('2019-01-01') # => true, since (rweek + 1) % 2 == 0
|
334
|
+
p c.match?('2019-01-08') # => false, since (rweek + 1) % 2 == 1
|
329
335
|
|
330
336
|
# ...
|
337
|
+
|
338
|
+
class EtOrbi::EoTime
|
339
|
+
def d # debug
|
340
|
+
"%14s | rday: %4d | rweek: %3d" % [ strftime('%F %a'), rday, rweek ]
|
341
|
+
end
|
342
|
+
end
|
343
|
+
|
344
|
+
c = Fugit.parse_cron('20 0 * * mon%2,wed%3+1')
|
345
|
+
puts c.next('2025-09-21').take(10).map(&:d)
|
346
|
+
#
|
347
|
+
# => 2025-09-24 Wed | rday: 2459 | rweek: 352
|
348
|
+
# 2025-09-29 Mon | rday: 2464 | rweek: 352
|
349
|
+
# 2025-10-13 Mon | rday: 2478 | rweek: 354
|
350
|
+
# 2025-10-15 Wed | rday: 2480 | rweek: 355
|
351
|
+
# 2025-10-27 Mon | rday: 2492 | rweek: 356
|
352
|
+
# 2025-11-05 Wed | rday: 2501 | rweek: 358
|
353
|
+
# 2025-11-10 Mon | rday: 2506 | rweek: 358
|
354
|
+
# 2025-11-24 Mon | rday: 2520 | rweek: 360
|
355
|
+
# 2025-11-26 Wed | rday: 2522 | rweek: 361
|
356
|
+
# 2025-12-08 Mon | rday: 2534 | rweek: 362
|
331
357
|
```
|
332
358
|
|
333
359
|
`sun%2` matches if Sunday and `current_date.rweek % 2 == 0`
|
334
360
|
`tue%3+2` matches if Tuesday and `current_date.rweek + 2 % 3 == 0`
|
335
361
|
`tue%x+y` matches if Tuesday and `current_date.rweek + y % x == 0`
|
336
362
|
|
363
|
+
```ruby
|
364
|
+
require 'et-orbi' # >= 1.4.0
|
365
|
+
|
366
|
+
class EtOrbi::EoTime
|
367
|
+
def d # debug
|
368
|
+
"%14s | rday: %4d | rweek: %3d" % [ strftime('%a'), rday, rweek ]
|
369
|
+
end
|
370
|
+
end
|
371
|
+
|
372
|
+
puts EtOrbi.parse('2018-12-30').d # => Sun | rday: -1 | rweek: -1
|
373
|
+
puts EtOrbi.parse('2018-12-31').d # => Mon | rday: 0 | rweek: 0 >REF<
|
374
|
+
puts EtOrbi.parse('2019-01-01').d # => Tue | rday: 1 | rweek: 0
|
375
|
+
puts EtOrbi.parse('2019-01-02').d # => Wed | rday: 2 | rweek: 0
|
376
|
+
puts EtOrbi.parse('2019-01-31').d # => Thu | rday: 31 | rweek: 4
|
377
|
+
|
378
|
+
puts EtOrbi.parse('2019-04-11').d # => Thu | rday: 101 | rweek: 14
|
379
|
+
puts EtOrbi.parse('2025-09-30').d # => Tue | rday: 2465 | rweek: 352
|
380
|
+
|
381
|
+
class EtOrbi::EoTime
|
382
|
+
def d # debug
|
383
|
+
"%14s | rday: %4d | rweek: %3d" % [ strftime('%F %a'), rday, rweek ]
|
384
|
+
end
|
385
|
+
end
|
386
|
+
|
387
|
+
p EtOrbi.rweek_ref # => "2018-12-31"
|
388
|
+
|
389
|
+
c = Fugit.parse_cron('20 0 * * mon%2,wed%3+1')
|
390
|
+
puts c.next('2025-09-21').take(10).map(&:d)
|
391
|
+
#
|
392
|
+
# => 2025-09-29 Mon | rday: 2464 | rweek: 352
|
393
|
+
# 2025-10-01 Wed | rday: 2466 | rweek: 352
|
394
|
+
# 2025-10-13 Mon | rday: 2478 | rweek: 354
|
395
|
+
# 2025-10-22 Wed | rday: 2487 | rweek: 355
|
396
|
+
# 2025-10-27 Mon | rday: 2492 | rweek: 356
|
397
|
+
# 2025-11-10 Mon | rday: 2506 | rweek: 358
|
398
|
+
# 2025-11-12 Wed | rday: 2508 | rweek: 358
|
399
|
+
# 2025-11-24 Mon | rday: 2520 | rweek: 360
|
400
|
+
# 2025-12-03 Wed | rday: 2529 | rweek: 361
|
401
|
+
# 2025-12-08 Mon | rday: 2534 | rweek: 362
|
402
|
+
```
|
403
|
+
|
404
|
+
One can tell et-orbi >= 1.4.0 which day to take as reference:
|
405
|
+
```ruby
|
406
|
+
EtOrbi.rweek_ref = :us # or
|
407
|
+
EtOrbi.rweek_ref = :sunday # to start on a Sunday (2018-12-30)
|
408
|
+
|
409
|
+
EtOrbi.rweek_ref = :iso # or
|
410
|
+
EtOrbi.rweek_ref = :monday # or
|
411
|
+
EtOrbi.rweek_ref = :default # to start on a Monday (2019-12-31)
|
412
|
+
|
413
|
+
EtOrbi.rweek_ref = :saturday # to start on, well, a Saturday (2019-01-05)
|
414
|
+
|
415
|
+
EtOrbi.rweek_ref = '2025-09-30' # to start on this very Tuesday...
|
416
|
+
|
417
|
+
p EtOrbi.rweek_ref # to determine what the current setting is...
|
418
|
+
```
|
419
|
+
|
337
420
|
|
338
421
|
### the second extension
|
339
422
|
|
data/fugit.gemspec
CHANGED
@@ -41,7 +41,7 @@ Time tools for flor and the floraison project. Cron parsing and occurrence compu
|
|
41
41
|
# this dependency appears in 'et-orbi'
|
42
42
|
|
43
43
|
s.add_runtime_dependency 'raabro', '~> 1.4'
|
44
|
-
s.add_runtime_dependency 'et-orbi', '~> 1
|
44
|
+
s.add_runtime_dependency 'et-orbi', '~> 1.4'
|
45
45
|
|
46
46
|
s.add_development_dependency 'rspec', '~> 3.8'
|
47
47
|
s.add_development_dependency 'chronic', '~> 0.10'
|
data/lib/fugit/cron.rb
CHANGED
@@ -175,34 +175,30 @@ module Fugit
|
|
175
175
|
|
176
176
|
def weekday_hash_match?(nt, hsh)
|
177
177
|
|
178
|
+
return false unless hsh.is_a?(Integer)
|
179
|
+
|
178
180
|
phsh, nhsh = nt.wday_in_month
|
181
|
+
#
|
182
|
+
# positive wday, from the beginning of the month
|
183
|
+
# negative wday, from the end of the month, -1 == last
|
179
184
|
|
180
|
-
|
181
|
-
hsh == phsh # positive wday, from the beginning of the month
|
182
|
-
else
|
183
|
-
hsh == nhsh # negative wday, from the end of the month, -1 == last
|
184
|
-
end
|
185
|
+
(hsh == phsh) || (hsh == nhsh)
|
185
186
|
end
|
186
187
|
|
187
188
|
def weekday_modulo_match?(nt, mod)
|
188
189
|
|
189
|
-
(
|
190
|
+
mod.is_a?(Array) &&
|
191
|
+
((nt.rweek % mod[0]) == (mod[1] % mod[0]))
|
190
192
|
end
|
191
193
|
|
192
194
|
def weekday_match?(nt)
|
193
195
|
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
if hom.is_a?(Array)
|
202
|
-
weekday_modulo_match?(nt, hom)
|
203
|
-
else
|
204
|
-
weekday_hash_match?(nt, hom)
|
205
|
-
end
|
196
|
+
@weekdays.nil? ||
|
197
|
+
@weekdays.find { |wd, hom|
|
198
|
+
(nt.wday == wd) &&
|
199
|
+
(hom.nil? ||
|
200
|
+
weekday_modulo_match?(nt, hom) ||
|
201
|
+
weekday_hash_match?(nt, hom)) }
|
206
202
|
end
|
207
203
|
|
208
204
|
def monthday_match?(nt)
|
data/lib/fugit.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fugit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.12.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Mettraux
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-
|
11
|
+
date: 2025-09-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: raabro
|
@@ -30,20 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '1'
|
34
|
-
- - ">="
|
35
|
-
- !ruby/object:Gem::Version
|
36
|
-
version: 1.2.11
|
33
|
+
version: '1.4'
|
37
34
|
type: :runtime
|
38
35
|
prerelease: false
|
39
36
|
version_requirements: !ruby/object:Gem::Requirement
|
40
37
|
requirements:
|
41
38
|
- - "~>"
|
42
39
|
- !ruby/object:Gem::Version
|
43
|
-
version: '1'
|
44
|
-
- - ">="
|
45
|
-
- !ruby/object:Gem::Version
|
46
|
-
version: 1.2.11
|
40
|
+
version: '1.4'
|
47
41
|
- !ruby/object:Gem::Dependency
|
48
42
|
name: rspec
|
49
43
|
requirement: !ruby/object:Gem::Requirement
|