Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Month is off by one in timestamp() #17

Open
sergei opened this issue Apr 7, 2021 · 0 comments
Open

Month is off by one in timestamp() #17

sergei opened this issue Apr 7, 2021 · 0 comments

Comments

@sergei
Copy link

sergei commented Apr 7, 2021

If timestamp() is called with no parameters the returned date is now minus one month:

   } else {
      var dt = new Date();
      year = dt.getUTCFullYear();
      month = dt.getUTCMonth();
      day = dt.getUTCDate();
    }

    /* construct */
    var d = new Date(Date.UTC(year, (month - 1), day, hours, minutes, seconds));

Probably the fix can be:

   } else {
      var dt = new Date();
      year = dt.getUTCFullYear();
      month = dt.getUTCMonth() + 1;  // [1;12] as in NMEA
      day = dt.getUTCDate();
    }

    /* construct */
    var d = new Date(Date.UTC(year, (month - 1), day, hours, minutes, seconds));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant