Comments (3)
Maximum allowed timeout in erlang is 4294967295 which is 2^32 -1.
This is however 49 days if I am calculating it correctly.
Which led me to 4835019000 which is approximately 56 days.
from erlcron.
The problem is that this month is 12th i.e. December and the code would always add one year and set month to one more however I am attempting to for example set a cronjob for the 26th of this month, but it sets it to next month.
My fix is to re-write the function to the following. This fixes multiple issues.
until_next_time(State, {{monthly, DoM, Period}, _What}) ->
{{ThisYear, ThisMonth, Today}, _} = current_date(State),
Days = case calendar:date_to_gregorian_days(ThisYear, ThisMonth, DoM) - calendar:date_to_gregorian_days(ThisYear, ThisMonth, Today) of
Res when Res < 0 ->
{NextYear, NextMonth} =
case ThisMonth of
12 ->
{ThisYear + 1, 1};
_ ->
{ThisYear, ThisMonth + 1}
end,
D1 = calendar:date_to_gregorian_days(ThisYear, ThisMonth, Today),
D2 = calendar:date_to_gregorian_days(NextYear, NextMonth, DoM),
D2 - D1;
Ds ->
Ds
end,
from erlcron.
Closing this as we're dropping the support for older releases of OTP
from erlcron.
Related Issues (20)
- erlcron needs more accessible documentation HOT 2
- erlcron conflicts with the UNIX at command HOT 2
- License is a bit weird HOT 1
- Scheduling a job in the past crashes erlcron HOT 2
- The documentation and last release are out of sync
- Jobs scheduled using 'daily' should work from today not from the next day HOT 1
- Inaccurate calculation of monthly timeout/apply time. HOT 1
- find a bug HOT 3
- Succesive calls to erlcron:datetime() return the same date HOT 2
- Fix -spec's for OTP-19 HOT 1
- syntax error before: '/' HOT 10
- Problems if the cron process crash or is canced. HOT 2
- update to hex.pm HOT 2
- test fails HOT 1
- {tag, "master"} ? HOT 2
- Looking for maintainer HOT 5
- Add milliseconds granularity to cron durations HOT 1
- Push lib to hex.pm HOT 3
- Application fails to start when jobs are defined in the config file HOT 1
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 erlcron.