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

Time zone issue when dealing with occurrences #152

Closed
stevschmid opened this issue Mar 4, 2013 · 1 comment
Closed

Time zone issue when dealing with occurrences #152

stevschmid opened this issue Mar 4, 2013 · 1 comment
Labels

Comments

@stevschmid
Copy link

I stumbled upon a time zone issue when dealing with Rails TimeWithZone and the occurrence finding methods (e.g. next_occurrence and occurrences_between).

Example: I create a schedule with starting_time in UTC and I'm calling the next_occurrence method with the opening_time argument set to a time in another time zone (e.g. GMT+1). The returned occurrence is not as the doc describes in the starting_time time zone (UTC), but in the time zone I supplied via the argument (GMT+1). More severe is that the time is wrong.

The example below reproduces the problem (ice_cube 0.10.0, Ruby 1.9.3 + Rails 3.2.12)

require 'ice_cube'
require 'active_support/time'
require 'active_support/core_ext'

schedule = IceCube::Schedule.new('2013-03-01 00:00:00 +00:00'.to_time)
schedule.add_recurrence_rule IceCube::Rule.daily
# schedule.start_time is 2013-03-01 00:00:00 UTC

reference_time = Time.new(2013,3,4).in_time_zone('Bern')
# reference_time is Fri, 01 Mar 2013 00:00:00 CET +01:00

p schedule.next_occurrence(reference_time)
# Tue, 05 Mar 2013 00:00:00 CET +01:00 (wrong time zone, wrong time)

p schedule.next_occurrence(reference_time).utc
#2013-03-04 23:00:00 UTC (wrong time)

p schedule.next_occurrence(reference_time.utc)
#2013-03-04 00:00:00 UTC (correct)

My first impression is that the find_occurrences function should make sure that the zones of opening_time and closing_time match the zone of starting_time.

@avit
Copy link
Collaborator

avit commented Mar 4, 2013

Thanks for the report, I'll have a look.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants