fugit 1.7.1 → 1.7.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: 318e360c503855580a65262f188ae07d02a17c1e833aeb5d8d21e25a67a9805c
4
- data.tar.gz: 54b9eaeba60e6c1a64db0ca2b5e86ed09e74d8c4afeb32677314946f8b1d5211
3
+ metadata.gz: d28dc94bc31e025df55b67c79f2f59eed365940872e287479e788cb9023178dd
4
+ data.tar.gz: 6f8d62b8d8921831a4de92d60a23c4cf83cfe79eea852c625744951156cb3d05
5
5
  SHA512:
6
- metadata.gz: c2813ab3974e9dcc7b3b6552bc8a5855617ac40b26190f84a3cbd413108d4b2ebc6a8c9418389a873844161289f60d48bece8fc10ca25295414e2e04c1da1474
7
- data.tar.gz: 6e8587a3894c801bc220f967e3f5b0fed6e1bdea0bc606841fe188f890c8a0f6756f4b5357fd4cd887ff7d9bfd0a6bde68a1405ff369f7b4d41b8ec3e14c1c4b
6
+ metadata.gz: 3afc5fd6553abed3c73d7526e25b871ba0f5f26b8f415fccfec183b261e5ccb4e9f3fc6b176b550fa47de385f8991efe08936d2d96d6951a15dba81533f2ebcc
7
+ data.tar.gz: e5cbdb64a9f6ee28e8f938c76dcdf44211ce751ca0dc1834d669b8494e40424fb7c5e8e98f7eb608e8855c29648b9c99e9faf06436ab05a795a87bffc771118c
data/CHANGELOG.md CHANGED
@@ -2,6 +2,12 @@
2
2
  # CHANGELOG.md
3
3
 
4
4
 
5
+ ## fugit 1.7.2 released 2022-11-03
6
+
7
+ * Fix 'every day at 12:15 am', gh-81
8
+ * Fix 'every day at 5:00pm', gh-81
9
+
10
+
5
11
  ## fugit 1.7.1 released 2022-09-21
6
12
 
7
13
  * Change behaviour for "0 0/5 * * *", gh-79
data/CREDITS.md CHANGED
@@ -1,6 +1,7 @@
1
1
 
2
2
  # fugit credits
3
3
 
4
+ * ski-nine, https://github.com/ski-nine, gh-81
4
5
  * Joseph Halter, https://github.com/JosephHalter, gh-79
5
6
  * James Healy, https://github.com/yob, gh-76
6
7
  * John Bachir, https://github.com/jjb, gh-74
data/README.md CHANGED
@@ -399,6 +399,36 @@ Fugit::Nat.parse('every day at 16:15 nada 18:30', multi: true)
399
399
  `"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.
400
400
 
401
401
 
402
+ ### 12 AM and PM
403
+
404
+ How does fugit react with `"12 am"`, `"12 pm"`, `"12 midnight"`, etc?
405
+
406
+ ```ruby
407
+ require 'fugit'
408
+
409
+ p Fugit.parse('every day at 12am').original # ==> "0 0 * * *"
410
+ p Fugit.parse('every day at 12pm').original # ==> "0 12 * * *"
411
+
412
+ p Fugit.parse('every day at 12:00am').original # ==> "0 0 * * *"
413
+ p Fugit.parse('every day at 12:00pm').original # ==> "0 12 * * *"
414
+ p Fugit.parse('every day at 12:00 am').original # ==> "0 0 * * *"
415
+ p Fugit.parse('every day at 12:00 pm').original # ==> "0 12 * * *"
416
+ p Fugit.parse('every day at 12:15am').original # ==> "15 0 * * *"
417
+ p Fugit.parse('every day at 12:15pm').original # ==> "15 12 * * *"
418
+ p Fugit.parse('every day at 12:15 am').original # ==> "15 0 * * *"
419
+ p Fugit.parse('every day at 12:15 pm').original # ==> "15 12 * * *"
420
+
421
+ p Fugit.parse('every day at 12 noon').original # ==> "0 12 * * *"
422
+ p Fugit.parse('every day at 12 midnight').original # ==> "0 24 * * *"
423
+ p Fugit.parse('every day at 12:00 noon').original # ==> "0 12 * * *"
424
+ p Fugit.parse('every day at 12:00 midnight').original # ==> "0 24 * * *"
425
+ p Fugit.parse('every day at 12:15 noon').original # ==> "15 12 * * *"
426
+ p Fugit.parse('every day at 12:15 midnight').original # ==> "15 24 * * *"
427
+
428
+ # as of fugit 1.7.2
429
+ ```
430
+
431
+
402
432
  ## LICENSE
403
433
 
404
434
  MIT, see [LICENSE.txt](LICENSE.txt)
data/lib/fugit/nat.rb CHANGED
@@ -176,6 +176,7 @@ module Fugit
176
176
  #'every week on monday 18:23' => '23 18 * * 1',
177
177
  #
178
178
  # every month on the 1st
179
+ #
179
180
  def on(i)
180
181
  seq(:on, i, :_on, :on_objects)
181
182
  end
@@ -196,12 +197,6 @@ module Fugit
196
197
  seq(nil, i, :_in_or_on, '?', :tz)
197
198
  end
198
199
 
199
- def digital_hour(i)
200
- rex(
201
- :digital_hour, i,
202
- /(2[0-4]|[0-1]?[0-9]):([0-5][0-9])([ \t]*(am|pm))?/i)
203
- end
204
-
205
200
  def ampm(i)
206
201
  rex(:ampm, i, /[ \t]*(am|pm|noon|midday|midnight)/i)
207
202
  end
@@ -209,6 +204,13 @@ module Fugit
209
204
  rex(:dark, i, /[ \t]*dark/i)
210
205
  end
211
206
 
207
+ def digital_h(i)
208
+ rex(:digital_h, i, /(2[0-4]|[0-1]?[0-9]):([0-5][0-9])/i)
209
+ end
210
+ def digital_hour(i)
211
+ seq(:digital_hour, i, :digital_h, :ampm, '?')
212
+ end
213
+
212
214
  def simple_h(i)
213
215
  rex(:simple_h, i, /#{(0..24).to_a.reverse.join('|')}/)
214
216
  end
@@ -451,20 +453,24 @@ module Fugit
451
453
  end
452
454
 
453
455
  def rewrite_tz(t)
456
+
454
457
  slot(:tz, t.string)
455
458
  end
456
459
 
457
460
  def rewrite_weekday(t)
461
+
458
462
  Fugit::Cron::Parser::WEEKDS.index(t.string[0, 3].downcase)
459
463
  end
460
464
 
461
465
  def rewrite_weekdays(t)
466
+
462
467
  #Raabro.pp(t, colours: true)
463
468
  slot(:weekday, _rewrite_subs(t, :weekday))
464
469
  end
465
470
  alias rewrite_on_weekdays rewrite_weekdays
466
471
 
467
472
  def rewrite_to_weekday(t)
473
+
468
474
  wd0, wd1 = _rewrite_subs(t, :weekday)
469
475
  #wd1 = 7 if wd1 == 0
470
476
  slot(:weekday, "#{wd0}-#{wd1}")
@@ -475,21 +481,35 @@ module Fugit
475
481
  slot(:monthday, "#{md0}-#{md1}")
476
482
  end
477
483
 
478
- def adjust_h(h, ap)
479
- h = h.to_i
480
- ap = ap || ''
481
- (h < 12 && ap == 'pm' || ap == 'midnight') ? h + 12 : h
484
+ # Try to follow https://en.wikipedia.org/wiki/12-hour_clock#Confusion_at_noon_and_midnight
485
+ #
486
+ def adjust_h(h, m, ap)
487
+
488
+ if ap == 'midnight' && h == 12
489
+ 24
490
+ elsif ap == 'pm' && h < 12 # post meridian
491
+ h + 12
492
+ elsif ap == 'am' && h == 12 # ante meridian
493
+ 0
494
+ else
495
+ h
496
+ end
482
497
  end
483
498
 
484
499
  def rewrite_digital_hour(t)
485
- h, m, ap = t.strinpd.split(/[: \t]+/)
486
- h, m = adjust_h(h, ap), m.to_i
500
+
501
+ h, m = t.sublookup(:digital_h).strinpd.split(':').collect(&:to_i)
502
+ ap = t.sublookup(:ampm)
503
+ h, m = adjust_h(h, m, ap && ap.strinpd), m
504
+
487
505
  slot(:hm, h, m)
488
506
  end
489
507
 
490
508
  def rewrite_simple_hour(t)
509
+
491
510
  h, ap = t.subgather(nil).collect(&:strinpd)
492
- h = adjust_h(h, ap)
511
+ h = adjust_h(h.to_i, 0, ap)
512
+
493
513
  slot(:hm, h, 0)
494
514
  end
495
515
 
@@ -501,12 +521,10 @@ module Fugit
501
521
 
502
522
  h = ht.strinp
503
523
  m = mt ? mt.strinp : 0
504
- #p [ 0, '-->', h, m ]
505
524
  h = NHOURS[h]
506
525
  m = NMINUTES[m] || m
507
- #p [ 1, '-->', h, m ]
508
526
 
509
- h = adjust_h(h, apt && apt.strinpd)
527
+ h = adjust_h(h, m, apt && apt.strinpd)
510
528
 
511
529
  slot(:hm, h, m)
512
530
  end
data/lib/fugit.rb CHANGED
@@ -3,7 +3,7 @@
3
3
 
4
4
  module Fugit
5
5
 
6
- VERSION = '1.7.1'
6
+ VERSION = '1.7.2'
7
7
  end
8
8
 
9
9
  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.7.1
4
+ version: 1.7.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Mettraux
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-09-21 00:00:00.000000000 Z
11
+ date: 2022-11-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: raabro
@@ -101,7 +101,7 @@ metadata:
101
101
  bug_tracker_uri: https://github.com/floraison/fugit/issues
102
102
  homepage_uri: https://github.com/floraison/fugit
103
103
  source_code_uri: https://github.com/floraison/fugit
104
- post_install_message:
104
+ post_install_message:
105
105
  rdoc_options: []
106
106
  require_paths:
107
107
  - lib
@@ -117,7 +117,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
117
117
  version: '0'
118
118
  requirements: []
119
119
  rubygems_version: 3.1.6
120
- signing_key:
120
+ signing_key:
121
121
  specification_version: 4
122
122
  summary: time tools for flor
123
123
  test_files: []