Comments (4)
FYI this happened since we migrated from lts-14.16
to resolver: lts-15.0
from cron.
After some investigation:
I think the problem is in System.Cron.Schedule.findNextMinuteDelay
, in particular on this line:
m = (read (formatTime defaultTimeLocale fmtMinutes now) :: Int) + 1
If the current minute is 59, then this returns 60
(thanks Captain Obvious!).
Now the interesting bit:
-- With time-1.8.0.2
λ> parseTimeOrError True defaultTimeLocale "%F %H:%M" "2020-02-26 17:60" :: UTCTime
2020-02-26 18:00:00 UTC
it :: UTCTime
-- With time-1.9.3
λ> parseTimeOrError True defaultTimeLocale "%F %H:%M" "2020-02-26 17:60" :: UTCTime
*** Exception: parseTimeOrError: no parse of "2020-02-26 17:60"
CallStack (from HasCallStack):
error, called at libraries/time/lib/Data/Time/Format/Parse.hs:82:12 in time-1.9.3:Data.Time.Format.Parse
The behavior changed in time
library!
Proposal:
- Extract the pure function so that it's testable in isolation (and actually add tests 😆 )
findNextMinuteDelay :: IO (UTCTime, Int)
findNextMinuteDelay = getCurrentTime >>= findNextMinuteDelay'
findNextMinuteDelay' :: UTCTime -> (UTCTime, Int)
findNextMinuteDelay' now = ...
- Simplify this function by:
- Relying on
addUTCTime
to first add a minute tonow
. This will be simpler and correctly handle the "off by 1" problem for 60 minutes - Manipulating seconds (numbers) instead of parsing
- Relying on
oneMinute :: NominalDiffTime
oneMinute = 60
addUTCTime oneMinute now
How does that sound?
Thank you!
If you (@MichaelXavier) are ok with this proposal, we (me or someone in my team) can try to propose a PR to apply those changes (but it would still be your duty to publish a new release to fix this bug).
Please let us know!
from cron.
@sir4ur0n I'd take that PR. Thanks for planning that out and stepping up to fix 😁
from cron.
good, maybe we can have it in for lts-15.3 ?
Nice work anyway removing partial parsing!
from cron.
Related Issues (20)
- Compatibility with stackage (older transformers library) HOT 7
- Support for mtl 2.2? HOT 3
- Failure to parse a schedule line should throw an exception HOT 4
- Incorrect timing for combinations of StepField and RangeField HOT 10
- Surviving exceptions
- cron-0.3.1 can't compile its test suite HOT 4
- Interpreting the schedule in a certain time zone HOT 7
- 0.4.0 doesn't compile with GHC <7.10 HOT 1
- Test suite failure HOT 8
- The leap second caused a scheduled job to run twice HOT 4
- Passing UTCTime to Job HOT 3
- Add @reboot non-standard schedule HOT 2
- Cron job is sometimes triggered twice in a row HOT 2
- Is this repo still maintained? HOT 2
- Publish back on Hackage/Stackage HOT 3
- Exposing System.Cron.Schedule.forkJob HOT 3
- [Idea] Non-overlapping cron jobs
- fails to build in ghc-9.6 stackage nightly
- System.Cron.Describe does not accept time zone settings HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cron.