fugit 1.4.3 → 1.5.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 30b1280ebc1d629dbbdcba1b02718a535b0fdec70c9d690f3d5208181ffe4577
4
- data.tar.gz: 918af2ece3f4c94eb1145b60da397a43ee574023831bae4b7c0b95e6a97e389b
3
+ metadata.gz: 8ea3f936965644ad47a2baf7b60d8a16825e8a92966bb5d4ca205f6f77205b0b
4
+ data.tar.gz: 00d9608f82444554090bf4839b93b8e2a5196ed6fab378770d06de49bf478a41
5
5
  SHA512:
6
- metadata.gz: 37b8ad132efdd2b9be99fb9fd1ab6f505024fd309865cf007d9ade6df20207a4165e49679a4113614010f7436ddbf28e2fc6ecbdbbedc713bb3e4def3f2b03ca
7
- data.tar.gz: 4fc6e3a8f080b698151cc6dadfb1d2869cb736a4e6c60ce7fe6c26a598f83b693d32f37edd1f42cd20dd0efdb47dd04cde097fca07d0bf5fe6eb9412b72ef0cf
6
+ metadata.gz: 1fe5f2034b40d4441c76e36075d9c9a6a31a54ac5c82e9c2961304f58875f75a2d63acd91a264f175b4ec16b74e98e46bd82bbd6e79619c2bd8f469804a4119b
7
+ data.tar.gz: 1668baf1ece5ab7d1a8198c67b4d659ab0f900113c7511761cb68242b13f9e4af581d109e46a523260aa9b55ec9d2442da47f680cd5c1794d03efebf5a81ba84
data/CHANGELOG.md CHANGED
@@ -2,6 +2,28 @@
2
2
  # CHANGELOG.md
3
3
 
4
4
 
5
+ ## fugit 1.5.1 released 2021-08-18
6
+
7
+ * Fix #next_time break issue for America/Santiago into DST, gh-60
8
+
9
+
10
+ ## fugit 1.5.0 released 2021-06-08
11
+
12
+ * Accept "at 12 noon" and "at 12 midday" as "* 12 * * *", gh-57
13
+ * Accept "at 12pm" as "0 12 * * *", not "0 24 * * *", gh-57
14
+ * Accept "15/30 * * * *" as "15-59/30 * * * *", gh-56
15
+
16
+
17
+ ## fugit 1.4.5 released 2021-04-22
18
+
19
+ * Accept "* * * Mon%2+2", gh-47
20
+
21
+
22
+ ## fugit 1.4.4 released 2021-03-25
23
+
24
+ * Ensure leaving ZH DST is OK, gh-53
25
+
26
+
5
27
  ## fugit 1.4.3 released 2021-03-23
6
28
 
7
29
  * Fix entering DST issue, gh-53
data/CREDITS.md CHANGED
@@ -1,6 +1,11 @@
1
1
 
2
2
  # fugit credits
3
3
 
4
+ * Ggallardoh https://github.com/Ggallardoh gh-60, America/Santiago into DST
5
+ * Khaled AbuShqear https://github.com/shqear93 gh-57, "12pm"
6
+ * John W Higgins https://github.com/wishdev gh-56, 15/30 cron decision
7
+ * Karen Sawrey https://github.com/karensawrey gh-47, Mon%2+1 rework idea
8
+ * Olle Jonsson https://github.com/olleolleolle gha Ruby 3.0
4
9
  * Andy Pfister https://github.com/andyundso gh-53, entering DST
5
10
  * Solteszad https://github.com/solteszad gh-51, fix previous_time vs last day of month
6
11
  * Niklas https://github.com/gr8bit gh-49, Fugit::Cron.parse('')
@@ -10,7 +15,7 @@
10
15
  * Danny Ben Shitrit https://github.com/DannyBen nat variants, gh-38
11
16
  * Dominik Sander https://github.com/dsander #rough_frequency 0, gh-36
12
17
  * Milovan Zogovic https://github.com/assembler Cron#match? vs TZ, gh-31
13
- * Jessica Stokes https://github.com/ticky 0-24 issue with cron, gh-30
18
+ * Jessica Stokes https://github.com/ticky 0-24 issue with cron, gh-30 and gh-47
14
19
  * Shai Coleman https://github.com/shaicoleman parse_nat enhancements, gh-24, gh-25, gh-28, and gh-37
15
20
  * Jan Stevens https://github.com/JanStevens Fugit.parse('every 15 minutes') gh-22
16
21
  * 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.rb CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Fugit
4
4
 
5
- VERSION = '1.4.3'
5
+ VERSION = '1.5.1'
6
6
  end
7
7
 
8
8
  require 'time'
data/lib/fugit/cron.rb CHANGED
@@ -83,17 +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
99
+
100
+ #inc( - @t.hour * 3600) if @t.hour != 0 # compensate for entering DST
101
+ #inc( - @t.hour * 3600) if @t.hour > 0 && @t.hour < 7
102
+ # leads to gh-60...
103
+
104
+ if @t.hour == 0
105
+ # it's good, carry on...
106
+ elsif @t.hour < 12
107
+ @t = ::EtOrbi.make(@t.year, @t.month, @t.day, @t.zone)
108
+ else
109
+ inc((24 - @t.hour) * 3600)
110
+ end
96
111
  end
112
+
97
113
  def inc_hour
98
114
  inc((60 - @t.min) * 60 - @t.sec)
99
115
  end
@@ -149,7 +165,7 @@ module Fugit
149
165
 
150
166
  def weekday_modulo_match?(nt, mod)
151
167
 
152
- nt.rweek % mod[0] == mod[1]
168
+ (nt.rweek + mod[1]) % mod[0] == 0
153
169
  end
154
170
 
155
171
  def weekday_match?(nt)
@@ -484,6 +500,8 @@ module Fugit
484
500
 
485
501
  sla = nil if sla == 1 # don't get fooled by /1
486
502
 
503
+ edn = max if sla && edn.nil?
504
+
487
505
  return [ nil ] if sta.nil? && edn.nil? && sla.nil?
488
506
  return [ sta ] if sta && edn.nil?
489
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
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.3
4
+ version: 1.5.1
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-23 00:00:00.000000000 Z
11
+ date: 2021-08-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