mongodb-cron icon indicating copy to clipboard operation
mongodb-cron copied to clipboard

Implement timezone support + Restore default UTC interpretation

Open chdanielmueller opened this issue 5 years ago • 7 comments

Before v1.5.0 the library did always use UTC time to parse the cron syntax. The change to cron-parser did alter this behavior. It now uses the local timezone as default. My proposal is to revert to the previous behavior as default to not create any breaking changes.

Another proposal is to allow the change of the tz of the cron-parser using a new option in mongodb-cron. This would allow the user to use any timezone he desires for the parsing of the intervals. The sleepUntil field is still saved as a UTC timestamp in any case.

closes #8

chdanielmueller avatar Apr 25 '19 09:04 chdanielmueller

Thank you @chdanielmueller. This is similar to what I wrote yesterday. We have to do two more things

  • The interpretation is not sufficient. When dates are modified in the database by the MongoCron process, the date must be formatted based on the configuration. For example, if I insert sleepUntil to the database using a timezone, the updated date must also be stored in this format and not the default Date() format. We can use moment-timezon package here.
  • We have to write tests to prove the functionality works. I played around with this yesterday and didn't find a nice solution just yet.

xpepermint avatar Apr 25 '19 12:04 xpepermint

To point 1: The default Date() format returns a timestamp in UTC timezone. For saving to the database I agree with you to say that this is best practice. This way we can also work around any other issues which might occur if the package works with timezones for all the logic. Basically just use the timezone for cron parsing. Or did I get something wrong?

To point 2: That's why I didn't add a test in my first PR. Don't know how to write a reasonable test for this.

chdanielmueller avatar Apr 25 '19 14:04 chdanielmueller

  1. Yes. I'll fix that first.
  2. I need to figure this out somehow :). Let me know if you come up with a reasonable code snippet :).

xpepermint avatar Apr 25 '19 14:04 xpepermint

@xpepermint Any timeline on this?

chdanielmueller avatar Jun 28 '19 13:06 chdanielmueller

Hey @chdanielmueller. Sorry, no timeline. My todo is filled with other tasks right now :(.

xpepermint avatar Jul 16 '19 11:07 xpepermint

@xpepermint Any news?

chdanielmueller avatar Apr 17 '20 12:04 chdanielmueller

Sorry, you'll have to use a fork until this is merged.

xpepermint avatar Apr 29 '20 08:04 xpepermint