Giter Site home page Giter Site logo

Comments (3)

stuartT4 avatar stuartT4 commented on August 24, 2024

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.

stuartT4 avatar stuartT4 commented on August 24, 2024

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.

Santiniis avatar Santiniis commented on August 24, 2024

Closing this as we're dropping the support for older releases of OTP

from erlcron.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.