fugit 1.4.4 → 1.5.2

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: 396cc931521c222b522a89e3840d3e1bd42e0927f20d5d3f0532122eafd62f74
4
- data.tar.gz: a04d54cd9894c593674031f704133f825769438e85a91330baaa42ad27089d68
3
+ metadata.gz: 7c15d1aa5444c8526cae61312916c90cde61e1e516faa8bdb330ade277ef3669
4
+ data.tar.gz: 5126ecd62951257326cb483e0b694ff4ffe7a02a7ef5eda53359e26aa43b43eb
5
5
  SHA512:
6
- metadata.gz: e97aebd235b532d3ad3a3df969b7189d1e628c3e1229d9d8d5a89b48fd552ebd856faf203289e9171df9b32e7a79b89ff33675799b83c6381eafc1f61945605e
7
- data.tar.gz: eaaed3254216b7082d8715990768d6b6588a864899e6911f74e967dfa83ed93221032420f82bd3f7215536365ee9340b2f2f6a2e175826456c9367d80d3ed9c4
6
+ metadata.gz: d04b7906c8134bc36f98a4cc3a5b598f430f1125c0169aa162cd8f789bb812479cdc17a65154ad6afb9f102b784d4d6a2831fe7a1512ef3a4b81ebe4eca22087
7
+ data.tar.gz: 1de022b1f39ba9a4f9cdeea4eed9427b1b33c3b9e121def7680a481b4036ad7542a4e5340814e7aa4a9937f03cc144b2fc2661975682b3683948cc4b7445bd0e
data/CHANGELOG.md CHANGED
@@ -2,6 +2,28 @@
2
2
  # CHANGELOG.md
3
3
 
4
4
 
5
+ ## fugit 1.5.2 released 2021-09-18
6
+
7
+ * Simplify inc_day, gh-62
8
+
9
+
10
+ ## fugit 1.5.1 released 2021-08-18
11
+
12
+ * Fix #next_time break issue for America/Santiago into DST, gh-60
13
+
14
+
15
+ ## fugit 1.5.0 released 2021-06-08
16
+
17
+ * Accept "at 12 noon" and "at 12 midday" as "* 12 * * *", gh-57
18
+ * Accept "at 12pm" as "0 12 * * *", not "0 24 * * *", gh-57
19
+ * Accept "15/30 * * * *" as "15-59/30 * * * *", gh-56
20
+
21
+
22
+ ## fugit 1.4.5 released 2021-04-22
23
+
24
+ * Accept "* * * Mon%2+2", gh-47
25
+
26
+
5
27
  ## fugit 1.4.4 released 2021-03-25
6
28
 
7
29
  * Ensure leaving ZH DST is OK, gh-53
data/CREDITS.md CHANGED
@@ -1,6 +1,11 @@
1
1
 
2
2
  # fugit credits
3
3
 
4
+ * Pascal Zumkehr https://github.com/codez gh-62, Santiago into DST vs Time.zone
5
+ * Ggallardoh https://github.com/Ggallardoh gh-60, America/Santiago into DST
6
+ * Khaled AbuShqear https://github.com/shqear93 gh-57, "12pm"
7
+ * John W Higgins https://github.com/wishdev gh-56, 15/30 cron decision
8
+ * Karen Sawrey https://github.com/karensawrey gh-47, Mon%2+1 rework idea
4
9
  * Olle Jonsson https://github.com/olleolleolle gha Ruby 3.0
5
10
  * Andy Pfister https://github.com/andyundso gh-53, entering DST
6
11
  * Solteszad https://github.com/solteszad gh-51, fix previous_time vs last day of month
@@ -11,7 +16,7 @@
11
16
  * Danny Ben Shitrit https://github.com/DannyBen nat variants, gh-38
12
17
  * Dominik Sander https://github.com/dsander #rough_frequency 0, gh-36
13
18
  * Milovan Zogovic https://github.com/assembler Cron#match? vs TZ, gh-31
14
- * Jessica Stokes https://github.com/ticky 0-24 issue with cron, gh-30
19
+ * Jessica Stokes https://github.com/ticky 0-24 issue with cron, gh-30 and gh-47
15
20
  * Shai Coleman https://github.com/shaicoleman parse_nat enhancements, gh-24, gh-25, gh-28, and gh-37
16
21
  * Jan Stevens https://github.com/JanStevens Fugit.parse('every 15 minutes') gh-22
17
22
  * Fabio Pitino https://github.com/hspazio nil on February 30 gh-21
data/README.md CHANGED
@@ -138,6 +138,8 @@ Example of cron strings understood by fugit:
138
138
  # and more...
139
139
  ```
140
140
 
141
+ Please note that `'15/30 * * * *'` is interpreted as `'15-59/30 * * * *'` since fugit 1.4.6.
142
+
141
143
  ### the first Monday of the month
142
144
 
143
145
  Fugit tries to follow the `man 5 crontab` documentation.
@@ -203,8 +205,22 @@ p EtOrbi.parse('2019-01-01').rweek % 2 # => 1
203
205
  p EtOrbi.parse('2019-04-11').wday # => 4
204
206
  p EtOrbi.parse('2019-04-11').rweek # => 15
205
207
  p EtOrbi.parse('2019-04-11').rweek % 2 # => 1
208
+
209
+ c = Fugit.parse('* * * * tue%2')
210
+ c.match?('2019-01-01') # => false, since rweek % 2 == 1
211
+ c.match?('2019-01-08') # => true, since rweek % 2 == 0
212
+
213
+ c = Fugit.parse('* * * * tue%2+1')
214
+ c.match?('2019-01-01') # => true, since (rweek + 1) % 2 == 0
215
+ c.match?('2019-01-08') # => false, since (rweek + 1) % 2 == 1
216
+
217
+ # ...
206
218
  ```
207
219
 
220
+ `sun%2` matches if Sunday and `current_date.rweek % 2 == 0`
221
+ `tue%3+2` matches if Tuesday and `current_date.rweek + 2 % 3 == 0`
222
+ `tue%x+y` matches if Tuesday and `current_date.rweek + y % x == 0`
223
+
208
224
 
209
225
  ## `Fugit::Duration`
210
226
 
data/lib/fugit/cron.rb CHANGED
@@ -83,18 +83,33 @@ module Fugit
83
83
  def dec(i); inc(-i); end
84
84
 
85
85
  def inc_month
86
+
86
87
  y = @t.year
87
88
  m = @t.month + 1
88
89
  if m == 13; m = 1; y += 1; end
90
+
89
91
  @t = ::EtOrbi.make(y, m, @t.zone)
92
+
90
93
  self
91
94
  end
92
95
 
93
96
  def inc_day
97
+
94
98
  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
99
+
100
+ return if @t.hour == 0
101
+
102
+ if @t.hour < 12
103
+ begin
104
+ @t = ::EtOrbi.make(@t.year, @t.month, @t.day, @t.zone)
105
+ rescue ::TZInfo::PeriodNotFound
106
+ inc((24 - @t.hour) * 3600)
107
+ end
108
+ else
109
+ inc((24 - @t.hour) * 3600)
110
+ end
97
111
  end
112
+
98
113
  def inc_hour
99
114
  inc((60 - @t.min) * 60 - @t.sec)
100
115
  end
@@ -150,7 +165,7 @@ module Fugit
150
165
 
151
166
  def weekday_modulo_match?(nt, mod)
152
167
 
153
- nt.rweek % mod[0] == mod[1]
168
+ (nt.rweek + mod[1]) % mod[0] == 0
154
169
  end
155
170
 
156
171
  def weekday_match?(nt)
@@ -485,6 +500,8 @@ module Fugit
485
500
 
486
501
  sla = nil if sla == 1 # don't get fooled by /1
487
502
 
503
+ edn = max if sla && edn.nil?
504
+
488
505
  return [ nil ] if sta.nil? && edn.nil? && sla.nil?
489
506
  return [ sta ] if sta && edn.nil?
490
507
 
data/lib/fugit/nat.rb CHANGED
@@ -201,7 +201,7 @@ module Fugit
201
201
  end
202
202
 
203
203
  def ampm(i)
204
- rex(:ampm, i, /[ \t]*(am|pm)/i)
204
+ rex(:ampm, i, /[ \t]*(am|pm|noon|midday|midnight)/i)
205
205
  end
206
206
  def dark(i)
207
207
  rex(:dark, i, /[ \t]*dark/i)
@@ -473,17 +473,21 @@ module Fugit
473
473
  slot(:monthday, "#{md0}-#{md1}")
474
474
  end
475
475
 
476
+ def adjust_h(h, ap)
477
+ h = h.to_i
478
+ ap = ap || ''
479
+ (h < 12 && ap == 'pm' || ap == 'midnight') ? h + 12 : h
480
+ end
481
+
476
482
  def rewrite_digital_hour(t)
477
483
  h, m, ap = t.strinpd.split(/[: \t]+/)
478
- h, m = h.to_i, m.to_i
479
- h += 12 if ap && ap == 'pm'
480
- slot(:hm, h.to_i, m.to_i)
484
+ h, m = adjust_h(h, ap), m.to_i
485
+ slot(:hm, h, m)
481
486
  end
482
487
 
483
488
  def rewrite_simple_hour(t)
484
489
  h, ap = t.subgather(nil).collect(&:strinpd)
485
- h = h.to_i
486
- h = h + 12 if ap == 'pm'
490
+ h = adjust_h(h, ap)
487
491
  slot(:hm, h, 0)
488
492
  end
489
493
 
@@ -500,7 +504,7 @@ module Fugit
500
504
  m = NMINUTES[m] || m
501
505
  #p [ 1, '-->', h, m ]
502
506
 
503
- h += 12 if h < 13 && apt && apt.strinpd == 'pm'
507
+ h = adjust_h(h, apt && apt.strinpd)
504
508
 
505
509
  slot(:hm, h, m)
506
510
  end
data/lib/fugit.rb CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Fugit
4
4
 
5
- VERSION = '1.4.4'
5
+ VERSION = '1.5.2'
6
6
  end
7
7
 
8
8
  require 'time'
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.4
4
+ version: 1.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Mettraux
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-03-25 00:00:00.000000000 Z
11
+ date: 2021-09-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: raabro
@@ -117,7 +117,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
117
117
  - !ruby/object:Gem::Version
118
118
  version: '0'
119
119
  requirements: []
120
- rubygems_version: 3.0.3
120
+ rubygems_version: 3.1.2
121
121
  signing_key:
122
122
  specification_version: 4
123
123
  summary: time tools for flor