-
Notifications
You must be signed in to change notification settings - Fork 262
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
Migrate cron expression to another timezone #243
Comments
The same use case is reported at Stackoverflow |
Is this really supposed to be a part of this utility? |
@SvenssonWeb there may be different ways to do this - we agree on that. Nevertheless, this use case may not be that straightforward: we may have cases where converting a cron expression to another timezone involve day changes, DST, etc. |
A real life example that I am looking at now. All of our servers globally run in their respective local time-zones. For various reasons, all our java apps run in UTC. We have a single app that needs to trigger tasks at various market times. e.g. The New York Close is at 17:00 NY time. The New Zealand Open is at 8am Wellington time, etc. We also need the ability to configure these tasks to run periodically (mostly for testing purposes). So a cron sort of suits, as it can handle both. So yes, we could look for specific times in the cron expression, and adjust them according to their Time Zone difference, but as OP suggested this would be cumbersome. Would be awesome if we could just pass the Cron through and TZ's be taken care of. |
@benjwarner thank you for the example provided! We will prioritize this issue for next release. You are also welcome to contribute 😄 Thanks! |
@jmrozanec Is this issue already taken? If not then i wish to work on it. |
@antrix190 work in it! We will be glad to merge your PR! Thanks! 😄 |
Sure! |
@antrix190 any news on this issue? It would be great to close October with a new release including this feature 😄 May seem as trivial as to replace current cron values with the GMT offset of the target timezone, but may become tricky when a block of hours gets split into two dates or similar cases. |
Hey @jmrozanec I need sometime to close this issue. |
@antrix190 sure! Seems easy, but has lots of corner cases :) thanks! |
@antrix190 if you need some help, do not hesitate to reach out on this thread and share code from your fork. Will be glad to provide assistance! 😄 |
can i pick this..? |
@fahmpeermoh sure! Will be happy to merge! |
@jmrozanec Thank you. |
Thank you guys for following up this feature :) |
@fahmpeermoh any news on this? |
The merged code doesn't work with multiple values in one field, e. g. In our case we have some auto-generated Jenkins jobs, performing scheduled tasks, which need to be adjusted to daylight saving time in some time zones. |
@Dizeee thank you for reporting this. May we ask you to point us the tests failing due to daylight savings in some timezones? This way we can fix them. If those are tests of your own, we would welcome them into our codebase, to ensure better quality. Thanks! 😄 |
@jmrozanec I'm talking about the tests in the pull request ;) https://github.com/jmrozanec/cron-utils/pull/400/files#diff-191b64506d58f9422b0b28100abfed44 |
First, thanks for the wonderful project! I'm working on a web-based project that uses Quartz Scheduler. The servers and the web application all run in UTC. However, clients will need to see the cron schedule expression reflected in their time zone. The new CronConverter() code seemed to be exactly what I needed. However, as @Dizeee mentioned, some of the use cases do not work as expected. For example, I would expect the following code:
To produce the string:
However, the returned string is the same as the input. Is this something that's intended to work as I expect or am I misunderstanding the intentions? |
Likewise, I'd expect:
To generate:
But it's generating:
Which is really wrong. |
Would this script help?
NOTE: Update difference_source_utc in the script to difference between your source and UTC.
|
@Jarvis017 this script is helpful! We will try to translate ASAP into our code. Meanwhile, you are welcome to contribute as well! Thanks! |
has this feature been added to cron-utils ?? or is it still open |
@kakumasn this feature was not added to cron-utils yet. Will do our best to include and test over next week. Will post an update when done and released. |
Hi Any updates on this |
Any update on this feature. |
@vishborade no updates 😄 If you have time, we will be glad to get some help on it. Thanks! |
I don't get why everyone's struggling so much with this issue :) That's how I do timezone conversions: Save your initial date in some timezone (like UTC) and calculate next launches with the same timezone, after that call ZonedDateTime#withZoneSameInstant(ZoneId) method and voilà, you've got your next launch with the timezone you need. |
@Haarolean can we wrap that into a method and a PR? 😄 |
Yeah, sure. Into the |
@Haarolean that would be great 😄 Thanks! |
Try this solution: https://www.npmjs.com/package/crontzconvert |
I need something like below:
Is it possible using cron-utils?
Let me give an example:
My local timezone is IST i.e. GMT+5.30.
Current local time is: 11:20 AM.
I want a job to run in 45 min of every hour.
So, my cron expression: 45 * * * *
Hence I am expecting my job to run after 25 min ( as starting time is 11:45 AM)
but my job is running as per UTC, because of oozie.
Current time in UTC : 05:50 AM
As per cron expression 45 * * * , the starting time will be 06:45 AM at GMT.
So, the job will be actually started after 55 min.
So,
This feature was originally reported at cron-utils-examples by @jrphub
The text was updated successfully, but these errors were encountered: