fugit 1.4.0 → 1.4.5

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of fugit might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 123f788edd6b7510be158be7ffdca00424eea5755aff767ae643180689947636
4
- data.tar.gz: c789eaf6ecf0ae363faafa8536b11b97e6c6e02af35983ae13f9c8649fe63ab3
3
+ metadata.gz: e49e2002591b450a853f0a27eb942fd69f69a59d6803c229bcdb51af471b6862
4
+ data.tar.gz: f9f6921007e4e0df0908e63f080d0f710ba60401299440347ecc994b6ccf56fc
5
5
  SHA512:
6
- metadata.gz: a7af25bbc69dcf5f891900d1620f171451a38ea269cb888ff440061ba0d8f1357a3789bcc446b71beba27a5029ad3214a65197d32165c4ed8e7fcc98fd25ad7e
7
- data.tar.gz: 89dad0285342e14e9ba1e346a1aae742775048c87bd569b1b8ec5a5edde914435cc3ffb414baa52b948b7af948e5c2cff9ea75cf61503133454eebf780eaebe3
6
+ metadata.gz: 22dc41bcc969d3505157572bbe899d7f160f8ab06ce42b3f4b494911ae69d96bde4be7422f55fd31c33491899b3af4ec50b4870f419145d103bd230d94affecd
7
+ data.tar.gz: 50d62627a4ed4fe54cf31d2901eebdd56f57a69f0464f0ede436184af604d1d18622e3159b487f9a92a35cfbf8a3ed65b58887dc3f43514e86a73e4db5d11692
data/CHANGELOG.md CHANGED
@@ -2,6 +2,32 @@
2
2
  # CHANGELOG.md
3
3
 
4
4
 
5
+ ## fugit 1.4.5 released 2021-04-22
6
+
7
+ * Accept "* * * Mon%2+2", gh-47
8
+
9
+
10
+ ## fugit 1.4.4 released 2021-03-25
11
+
12
+ * Ensure leaving ZH DST is OK, gh-53
13
+
14
+
15
+ ## fugit 1.4.3 released 2021-03-23
16
+
17
+ * Fix entering DST issue, gh-53
18
+
19
+
20
+ ## fugit 1.4.2 released 2021-01-12
21
+
22
+ * Fix Fugit::Cron.previous_time vs last day of month, gh-51
23
+ * Let Fugit::Cron.parse('') return nil, gh-49
24
+
25
+
26
+ ## fugit 1.4.1 released 2020-11-25
27
+
28
+ * Suppress warning, gh-46, thanks @amatsuda
29
+
30
+
5
31
  ## fugit 1.4.0 released 2020-10-27
6
32
 
7
33
  * Ensure cron accepts "25-L" for monthday, gh-45
data/CREDITS.md CHANGED
@@ -1,12 +1,18 @@
1
1
 
2
2
  # fugit credits
3
3
 
4
+ * Karen Sawrey https://github.com/karensawrey gh-47, Mon%2+1 rework idea
5
+ * Olle Jonsson https://github.com/olleolleolle gha Ruby 3.0
6
+ * Andy Pfister https://github.com/andyundso gh-53, entering DST
7
+ * Solteszad https://github.com/solteszad gh-51, fix previous_time vs last day of month
8
+ * Niklas https://github.com/gr8bit gh-49, Fugit::Cron.parse('')
9
+ * Matsuda Akira https://github.com/amatsuda gh-46, warning suppression
4
10
  * Honglooker https://github.com/honglooker gh-43, New York cron skip
5
11
  * Jérôme Dalbert https://github.com/jeromedalbert gh-41, gh-42
6
12
  * Danny Ben Shitrit https://github.com/DannyBen nat variants, gh-38
7
13
  * Dominik Sander https://github.com/dsander #rough_frequency 0, gh-36
8
14
  * Milovan Zogovic https://github.com/assembler Cron#match? vs TZ, gh-31
9
- * Jessica Stokes https://github.com/ticky 0-24 issue with cron, gh-30
15
+ * Jessica Stokes https://github.com/ticky 0-24 issue with cron, gh-30 and gh-47
10
16
  * Shai Coleman https://github.com/shaicoleman parse_nat enhancements, gh-24, gh-25, gh-28, and gh-37
11
17
  * Jan Stevens https://github.com/JanStevens Fugit.parse('every 15 minutes') gh-22
12
18
  * Fabio Pitino https://github.com/hspazio nil on February 30 gh-21
data/LICENSE.txt CHANGED
@@ -1,5 +1,5 @@
1
1
 
2
- Copyright (c) 2017-2020, John Mettraux, jmettraux+flor@gmail.com
2
+ Copyright (c) 2017-2021, John Mettraux, jmettraux+flor@gmail.com
3
3
 
4
4
  Permission is hereby granted, free of charge, to any person obtaining a copy
5
5
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
 
2
2
  # fugit
3
3
 
4
- [![Build Status](https://secure.travis-ci.org/floraison/fugit.svg)](http://travis-ci.org/floraison/fugit)
4
+ [![tests](https://github.com/floraison/fugit/workflows/test/badge.svg)](https://github.com/floraison/fugit/actions)
5
5
  [![Gem Version](https://badge.fury.io/rb/fugit.svg)](http://badge.fury.io/rb/fugit)
6
6
  [![Join the chat at https://gitter.im/floraison/fugit](https://badges.gitter.im/floraison/fugit.svg)](https://gitter.im/floraison/fugit?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
7
7
 
@@ -203,8 +203,22 @@ p EtOrbi.parse('2019-01-01').rweek % 2 # => 1
203
203
  p EtOrbi.parse('2019-04-11').wday # => 4
204
204
  p EtOrbi.parse('2019-04-11').rweek # => 15
205
205
  p EtOrbi.parse('2019-04-11').rweek % 2 # => 1
206
+
207
+ c = Fugit.parse('* * * * tue%2')
208
+ c.match?('2019-01-01') # => false, since rweek % 2 == 1
209
+ c.match?('2019-01-08') # => true, since rweek % 2 == 0
210
+
211
+ c = Fugit.parse('* * * * tue%2+1')
212
+ c.match?('2019-01-01') # => true, since (rweek + 1) % 2 == 0
213
+ c.match?('2019-01-08') # => false, since (rweek + 1) % 2 == 1
214
+
215
+ # ...
206
216
  ```
207
217
 
218
+ `sun%2` matches if Sunday and `current_date.rweek % 2 == 0`
219
+ `tue%3+2` matches if Tuesday and `current_date.rweek + 2 % 3 == 0`
220
+ `tue%x+y` matches if Tuesday and `current_date.rweek + y % x == 0`
221
+
208
222
 
209
223
  ## `Fugit::Duration`
210
224
 
@@ -350,6 +364,10 @@ Fugit::Nat.parse('every day at 16:15 nada 18:30', multi: true)
350
364
 
351
365
  `multi: false` is the default behaviour, return a single `Fugit::Cron` instance or nil when it cannot parse.
352
366
 
367
+ ### Nat Midnight
368
+
369
+ `"Every day at midnight"` is supported, but `"Every monday at midnight"` will be interpreted (as of Fugit <= 1.4.x) as `"Every monday at 00:00"`. Sorry about that.
370
+
353
371
 
354
372
  ## LICENSE
355
373
 
data/lib/fugit.rb CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Fugit
4
4
 
5
- VERSION = '1.4.0'
5
+ VERSION = '1.4.5'
6
6
  end
7
7
 
8
8
  require 'time'
data/lib/fugit/cron.rb CHANGED
@@ -79,10 +79,7 @@ module Fugit
79
79
  %w[ year month day wday hour min sec wday_in_month rweek rday ]
80
80
  .collect(&:to_sym).each { |k| define_method(k) { @t.send(k) } }
81
81
 
82
- def inc(i)
83
- @t = @t + i
84
- self
85
- end
82
+ def inc(i); @t = @t + i; self; end
86
83
  def dec(i); inc(-i); end
87
84
 
88
85
  def inc_month
@@ -95,6 +92,8 @@ module Fugit
95
92
 
96
93
  def inc_day
97
94
  inc((24 - @t.hour) * 3600 - @t.min * 60 - @t.sec)
95
+ #inc( - @t.hour * 3600) if @t.hour != 0 # compensate for entering DST
96
+ inc( - @t.hour * 3600) if @t.hour > 0 && @t.hour < 7
98
97
  end
99
98
  def inc_hour
100
99
  inc((60 - @t.min) * 60 - @t.sec)
@@ -112,12 +111,7 @@ module Fugit
112
111
  end
113
112
 
114
113
  def dec_month
115
-
116
- #dec(@t.day * 24 * 3600 + @t.hour * 3600 + @t.min * 60 + @t.sec + 1)
117
- #
118
- # gh-18, so that '0 9 29 feb *' doesn't get skipped (over and over)
119
- #
120
- dec(@t.day * 24 * 3600 + 1)
114
+ dec((@t.day - 1) * DAY_S + @t.hour * 3600 + @t.min * 60 + @t.sec + 1)
121
115
  end
122
116
 
123
117
  def dec_day
@@ -156,7 +150,7 @@ module Fugit
156
150
 
157
151
  def weekday_modulo_match?(nt, mod)
158
152
 
159
- nt.rweek % mod[0] == mod[1]
153
+ (nt.rweek + mod[1]) % mod[0] == 0
160
154
  end
161
155
 
162
156
  def weekday_match?(nt)
@@ -337,7 +331,7 @@ module Fugit
337
331
  [ :seconds, 1, 60 ],
338
332
  [ :minutes, 60, 60 ],
339
333
  [ :hours, 3600, 24 ],
340
- [ :days, 24 * 3600, 365 ] ].freeze
334
+ [ :days, DAY_S, 365 ] ].freeze
341
335
 
342
336
  def rough_frequency
343
337
 
@@ -379,7 +373,7 @@ module Fugit
379
373
 
380
374
  @delta_min = deltas.min; @delta_max = deltas.max
381
375
  @occurrences = deltas.size
382
- @span_years = span / (365 * 24 * 3600)
376
+ @span_years = span / YEAR_S
383
377
  @yearly_occurrences = @occurrences.to_f / @span_years
384
378
  end
385
379
 
@@ -780,8 +774,12 @@ module Fugit
780
774
 
781
775
  def rewrite_cron(t)
782
776
 
783
- hcron = t
777
+ st = t
784
778
  .sublookup(nil) # go to :ccron or :scron
779
+
780
+ return nil unless st
781
+
782
+ hcron = st
785
783
  .subgather(nil) # list min, hou, mon, ...
786
784
  .inject({}) { |h, tt|
787
785
  h[tt.name] = tt.name == :tz ? rewrite_tz(tt) : rewrite_entry(tt)
@@ -61,10 +61,10 @@ module Fugit
61
61
  end
62
62
 
63
63
  KEYS = {
64
- yea: { a: 'Y', r: 'y', i: 'Y', s: 365 * 24 * 3600, x: 0, l: 'year' },
65
- mon: { a: 'M', r: 'M', i: 'M', s: 30 * 24 * 3600, x: 1, l: 'month' },
66
- wee: { a: 'W', r: 'w', i: 'W', s: 7 * 24 * 3600, I: true, l: 'week' },
67
- day: { a: 'D', r: 'd', i: 'D', s: 24 * 3600, I: true, l: 'day' },
64
+ yea: { a: 'Y', r: 'y', i: 'Y', s: YEAR_S, x: 0, l: 'year' },
65
+ mon: { a: 'M', r: 'M', i: 'M', s: 30 * DAY_S, x: 1, l: 'month' },
66
+ wee: { a: 'W', r: 'w', i: 'W', s: 7 * DAY_S, I: true, l: 'week' },
67
+ day: { a: 'D', r: 'd', i: 'D', s: DAY_S, I: true, l: 'day' },
68
68
  hou: { a: 'h', r: 'h', i: 'H', s: 3600, I: true, l: 'hour' },
69
69
  min: { a: 'm', r: 'm', i: 'M', s: 60, I: true, l: 'minute' },
70
70
  sec: { a: 's', r: 's', i: 'S', s: 1, I: true, l: 'second' } }.freeze
data/lib/fugit/misc.rb CHANGED
@@ -2,6 +2,9 @@
2
2
 
3
3
  module Fugit
4
4
 
5
+ DAY_S = (24 * 3600).freeze
6
+ YEAR_S = (365 * DAY_S).freeze
7
+
5
8
  class << self
6
9
 
7
10
  def isostamp(show_date, show_time, show_usec, time)
data/lib/fugit/nat.rb CHANGED
@@ -407,7 +407,7 @@ module Fugit
407
407
  #when 'm' then slot(:m, pts)
408
408
  when 'm' then slot(:hm, '*', pts, strong: 1)
409
409
  when 's' then slot(:second, pts)
410
- else slot(pt.to_sym, pts)
410
+ else slot(pt.to_sym, pts)
411
411
  end
412
412
  end
413
413
 
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.0
4
+ version: 1.4.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Mettraux
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-10-27 00:00:00.000000000 Z
11
+ date: 2021-04-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: raabro