Closed andyundso closed 3 years ago
Hello,
thanks for the report. I am working on it.
As a workaround, you could use "every tuesday at 00:00"
as seen in https://github.com/floraison/fugit/blob/49b66702bc309bcffd8e5d7495dd45f080bf134c/spec/cron_spec.rb#L265-L288
I think I am guilty of interpreting "every monday at midnight"
as "every monday at 00:00"
. I need to straighten that.
Now, I still have to double-check, the entrance into DST is done at 02:00, it should make a 00:00 schedule skip.
@andyundso
Hello, could you please tell me if the above fix suits you? If yes, I will release 1.4.3.
require 'fugit'
ENV['TZ'] = 'Europe/Zurich'
t0 = Time.parse('2021-03-22 13:00')
p Fugit.parse('every monday at midnight').next_time(t0).to_s
# ==> "2021-03-29 00:00:00 +0200"
# and not "2021-04-05 00:00:00 +0200"
Best regards.
Good morning @jmettraux
Many thanks for the quick reaction. I tested the master branch with our test and now it works. I think you can release 1.4.3.
Best regards, Andy
It's released https://rubygems.org/gems/fugit/versions/1.4.3
Thanks again!
@andyundso
Hello,
for the sake of completeness, I added a spec for when leaving the DST (October) and it failed. I have fixed the problem and released 1.4.4. https://github.com/floraison/fugit/commit/550e571d0af076d918459c432bbd850245cf0702
Please upgrade before October.
Best regards.
Issue description
First of all, I'm based in Switzerland. Our clock will change next week to summer time. We use Fugit in a project to allow users schedule background jobs. We have a test suite that has a test where a job should run each week with the instruction
every monday at midnight
. We compare the result of Fugit with an expected value to make sure our scheduler works.Now, instructing Fugit to give the next date for said schedule strangely gives a date in two weeks instead of next week. Other hours seem to work fine:
I'm not sure if it is related to DST and if this is supposed to happen (I don't know cron too well).
How to reproduce
See above.
Error and error backtrace (if any)
Not needed, as no error will be printed.
Expected behaviour
next_time
should printMon, 29 Mar 2021 00:00:00 CEST +02:00
.Context
Please replace the content of this section with the output of the following commands:
(It's supposed to look like
)