Comments (4)
Hello,
for comparison:
then in the UTC timezone:
require 'fugit'
ENV['TZ'] = 'UTC'
t0 = Time.parse('2022-09-20 09:00:00 +0000')
#> Fugit.do_parse("0 * * * * Asia/Tokyo").next_time.to_s
#=> "2022-09-20 10:00:00 +0000"
p Fugit.do_parse('0 * * * *').next_time(t0).to_s
p Fugit.do_parse('0 * * * *').next_time(t0).utc.to_s
# ==> "2022-09-20 10:00:00 Z"
# ==> "2022-09-20 10:00:00 UTC"
p Fugit.do_parse('0 * * * * Asia/Tokyo').next_time(t0).to_s
p Fugit.do_parse('0 * * * * Asia/Tokyo').next_time(t0).utc.to_s
# ==> "2022-09-20 10:00:00 Z"
# ==> "2022-09-20 10:00:00 UTC"
#> Fugit.do_parse("0 */1 * * * Asia/Tokyo").next_time.to_s
#=> "2022-09-20 10:00:00 +0000"
p Fugit.do_parse('0 */1 * * *').next_time(t0).to_s
p Fugit.do_parse('0 */1 * * *').next_time(t0).utc.to_s
# ==> "2022-09-20 10:00:00 Z"
# ==> "2022-09-20 10:00:00 UTC"
p Fugit.do_parse('0 */1 * * * Asia/Tokyo').next_time(t0).to_s
p Fugit.do_parse('0 */1 * * * Asia/Tokyo').next_time(t0).utc.to_s
# ==> "2022-09-20 10:00:00 Z"
# ==> "2022-09-20 10:00:00 UTC"
#> Fugit.do_parse("0 0/1 * * * Asia/Tokyo").next_time.to_s
#=> "2022-09-20 15:00:00 +0000"
p Fugit.do_parse('0 0/1 * * *').next_time(t0).to_s
p Fugit.do_parse('0 0/1 * * *').next_time(t0).utc.to_s
# ==> "2022-09-21 00:00:00 Z"
# ==> "2022-09-21 00:00:00 UTC"
p Fugit.do_parse('0 0/1 * * * Asia/Tokyo').next_time(t0).to_s
p Fugit.do_parse('0 0/1 * * * Asia/Tokyo').next_time(t0).utc.to_s
# ==> "2022-09-20 15:00:00 Z"
# ==> "2022-09-20 15:00:00 UTC"
and in the Tokyo timezone:
require 'fugit'
ENV['TZ'] = 'Asia/Tokyo'
t0 = Time.parse('2022-09-20 09:00:00 +0000')
#> Fugit.do_parse("0 * * * * Asia/Tokyo").next_time.to_s
#=> "2022-09-20 10:00:00 +0000"
p Fugit.do_parse('0 * * * *').next_time(t0).to_s
p Fugit.do_parse('0 * * * *').next_time(t0).utc.to_s
# ==> "2022-09-20 19:00:00 +0900"
# ==> "2022-09-20 10:00:00 UTC"
p Fugit.do_parse('0 * * * * Asia/Tokyo').next_time(t0).to_s
p Fugit.do_parse('0 * * * * Asia/Tokyo').next_time(t0).utc.to_s
# ==> "2022-09-20 19:00:00 +0900"
# ==> "2022-09-20 10:00:00 UTC"
#> Fugit.do_parse("0 */1 * * * Asia/Tokyo").next_time.to_s
#=> "2022-09-20 10:00:00 +0000"
p Fugit.do_parse('0 */1 * * *').next_time(t0).to_s
p Fugit.do_parse('0 */1 * * *').next_time(t0).utc.to_s
# ==> "2022-09-20 19:00:00 +0900"
# ==> "2022-09-20 10:00:00 UTC"
p Fugit.do_parse('0 */1 * * * Asia/Tokyo').next_time(t0).to_s
p Fugit.do_parse('0 */1 * * * Asia/Tokyo').next_time(t0).utc.to_s
# ==> "2022-09-20 19:00:00 +0900"
# ==> "2022-09-20 10:00:00 UTC"
#> Fugit.do_parse("0 0/1 * * * Asia/Tokyo").next_time.to_s
#=> "2022-09-20 15:00:00 +0000"
p Fugit.do_parse('0 0/1 * * *').next_time(t0).to_s
p Fugit.do_parse('0 0/1 * * *').next_time(t0).utc.to_s
# ==> "2022-09-21 00:00:00 +0900"
# ==> "2022-09-20 15:00:00 UTC"
p Fugit.do_parse('0 0/1 * * * Asia/Tokyo').next_time(t0).to_s
p Fugit.do_parse('0 0/1 * * * Asia/Tokyo').next_time(t0).utc.to_s
# ==> "2022-09-21 00:00:00 +0900"
# ==> "2022-09-20 15:00:00 UTC"
However when combined with a timezone, it seems like they aren't equivalent anymore, at least for Fugit:
How so? In the two batch of tests I ran above, fugit gives equivalent results with and without a timezone given in the cron string.
from fugit.
this is probably what you are trying to hint at, I see the problem, but it is not linked to the timezone.
require 'fugit'
p Fugit.do_parse('0 * * * *').hours # ==> nil
p Fugit.do_parse('0 * * * * Asia/Tokyo').hours # ==> nil
p Fugit.do_parse('0 /1 * * *').hours # ==> nil
p Fugit.do_parse('0 /1 * * * Asia/Tokyo').hours # ==> nil
p Fugit.do_parse('0 0/1 * * *').hours # ==> [ 0 ]
p Fugit.do_parse('0 0/1 * * * Asia/Tokyo').hours # ==> [ 0 ]
# nil indicates that the cron should trigger at every hour
# [ 0 ] indicates that the cron should trigger at hour 0
from fugit.
I see the problem, but it is not linked to the timezone [...]
You're correct indeed. Thank you for the very quick fix, I'll update the gem to the new version as soon as you release it 👍
from fugit.
Just released fugit 1.7.1 https://rubygems.org/gems/fugit/versions/1.7.1
Thanks a lot!
from fugit.
Related Issues (20)
- multi-headed Fugit::Cron instance
- Specify which sidekiq-cron version is available HOT 2
- Specify which sidekiq-cron version is available HOT 5
- Regression with parsing in 1.9+ HOT 5
- Behaviour change between 1.4.4 and 1.4.5 HOT 8
- be liberal with extra commas
- Implement the & cron modifier HOT 1
- Introduce OpenBSD cron ~ notation HOT 1
- Fugit.parse incorrectly parsing am/pm HOT 5
- time computation with monthly duration like "P-2M" is incorrect
- Un-representable inputs should raise an error HOT 4
- Incorrect next_time for cron that is supposed to run every 3 hours for America/New_York HOT 3
- If given 6 fields, the first one is interpreted as seconds HOT 2
- Version 1.10.0 not compatible with ruby 2.2.6 HOT 8
- Examples in Readme don't work: undefined method 'next' for Fugit::Cron HOT 1
- cron #previous_time loop breaker issue HOT 6
- cron #previous_time loop breaker issue HOT 3
- #next_time breaks on DST end HOT 4
- Cron inconsistent behaviour with union vs intersection HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fugit.