Skip to content

Schedule losing timezone when serialized with ical #439

Open

Description

@Rockster160

Ruby 2.3.1
Rails 5.0.2
IceCube 0.16.2

schedule = IceCube::Schedule.new(Time.now.in_time_zone(-6))
=> #<IceCube::Schedule:0x005592aed59940 @start_time=Fri, 23 Mar 2018 19:53:42 CST -06:00, @all_recurrence_rules=[], @all_exception_rules=[]>
> schedule.start_time
=> Fri, 23 Mar 2018 19:53:42 CST -06:00
> IceCube::Schedule.from_ical(schedule.to_ical).start_time
=> 2018-03-23 19:53:42 +0000

Notice it goes from 7:53 PM CST to 7:53 PM UTC - losing the accuracy of the time as well as dropping the time zone.

Activity

  1. hbhanoo commented on Jun 23, 2021

    @hbhanoo

    I just noticed this too!

  2. sergioisidoro commented on Jun 17, 2025

    @sergioisidoro

    I'm having the opposite issue (de-serialization, not serialization)

    > schedule = IceCube::Schedule.new(Time.current)
    {
        :start_time => {
            :time => 2025-06-17 15:06:35.246698923 UTC,
            :zone => "Europe/Helsinki"
        },
            :rrules => [],
            :rtimes => [],
           :extimes => []
    }
    
    > rule = IceCube::Rule.daily(1000).day_of_week(tuesday: [1, -1], wednesday: [2])
    > schedule.add_recurrence_rule(rule)
    > ical_string = schedule.to_ical
    "DTSTART;TZID=EEST:20250617T180635\nRRULE:FREQ=DAILY;INTERVAL=1000;BYDAY=1TU,-1TU,2WE"
    
    > ice_cube = IceCube::Schedule.from_ical(ical_string)
    {
        :start_time => 2025-06-17 18:06:35 +0000,
        ...
    }
    

    Serialization is working with timezones, and string is correctly generated. But when I do from_ical it defaults to UTC and loses timezone (note that 18:06:35 +0000 should actually be 15:06:35 UTC or 18:06:35 EEST)

    Edit: found something very interesting in the specs of RFC2445:

    The TZID property parameter MUST NOT be applied to DATE-TIME or TIME
    properties whose time values are specified in UTC.

    However we see that the time string is being serialized to :20250617T180635 which is in local time. There ical_format(time, force_utc), which If i read things correctly should ALWAYS be UTC.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions