kelektiv / node-cron

Cron for NodeJS.
MIT License
8.31k stars 617 forks source link

Timezone Europe/Helsinki triggers onTick every seconds #764

Closed obriankevin11 closed 8 months ago

obriankevin11 commented 8 months ago

Description

    const job= CronJob.from({
        cronTime: '0 0 8 * * *',
        onTick: myFunction,
        start: true,
        timeZone: 'Europe/Helsinki',
    });

with version "cron": "^3.1.6",

myFunction is triggered every seconds...where as it works fine with Europe/Paris. Is it because Hel tz is not handled somehow? Couldn't find a list of permitted Tz for the lib, only this https://en.wikipedia.org/wiki/List_of_tz_database_time_zones

Expected Behavior

myFunction triggers every day at 8

Actual Behavior

myFunction triggers every second

Possible Fix

Change timezone

Steps to Reproduce

see description

Context

Trigger myFunction every day at 8

Your Environment

sheerlox commented 8 months ago

hi, I tried reproducing your issue on both Linux Ubuntu & Windows 10, using Node 16.17.0, without luck. Here's the exact code and setup I used: https://github.com/sheerlox/node-cron-test/blob/main/src/issues/764.ts

could you try cloning the repository and running that file to confirm if the issue persists?

git clone https://github.com/sheerlox/node-cron-test.git
cd node-cron-test
npm install
npm run build
node .\dist\issues\764.js

also, we rely on luxon for handling time zones, and their docs state:

If you specify a zone and your environment doesn't support that zone, you'll get an invalid DateTime.

obriankevin11 commented 8 months ago

hmm I don't know what I did to get the failure but now it works ok. Sorry for the inconvenience.