NSCalendarDate saving and loading to get the same date-time (Floating Timezone)

  • Hi Shawn,
    I finally found the term and an example for what I am trying to do. I am
    trying to implement a floating timezone in my application.

    Try this.
    1. In iCal create an event (note the date-time of the event).
    2. Quit iCal and In System Preferences change the timezone (different
    continent preferably)
    3. Launch iCal again and note the date-time of the event. It will be
    different and it is correct because the date-time is adjusted based on the
    timezone.
    4. Now change the timezone back to the original timezone.
    5. Quit and launch iCal.
    5. In iCal preferences (Advanced) check the "Turn on time zone support".
    6. Edit the iCal event and set the timezone to "Floating" (In the Info
    drawer of the event).
    7. Quit iCal.
    8. Change the timezone in the System Preferences and run iCal. The date-time
    is the same as the original date-time (that is it is not adjusted based on
    the time zone).

    Sorry I couldn't explain it better before without an example application
    doing the same. Any suggestions on how to implement this feature? Thank you.

    Regards
    Sarat

    On 10/9/06, Shawn Erickson <shawnce...> wrote:
    >
    >
    > On Oct 9, 2006, at 2:09 PM, Sarat Kongara wrote:
    >
    >> Thanks Shawn. I understand the NSDate behaviour better now. I guess
    >> the best option for me is to save the Timezone with the dates so I can
    >> adjust them on load or save the components individually
    >> (mm,dd,yyyy,hh,mm,ss).
    >
    > I still don't understand what your issue is. The NSDate you save is
    > the same one you get back when you load what you saved (same in the
    > sense that it represents the same exact time). You should have no
    > need to adjust anything.
    >
    > Can you better describe the problem you are trying to solve?
    >
    > -Shawn
    >
  • In that case I would define that your "floating" date is to be
    interpreted using a single reference time zone, likely best to use
    GMT. In other words whenever you want to visually display this date
    you always use your reference time zone (not the current time zone of
    the system). Basically time zone is not important for a "floating"
    date/time so make it a fixed value.

    The various date APIs have methods to deal with dates in a specific time zone.

    -Shawn

    On 10/10/06, Sarat Kongara <saratkongara...> wrote:
    > Hi Shawn,
    >
    > I finally found the term and an example for what I am trying to do. I am
    > trying to implement a floating timezone in my application.
    >
    > Try this.
    > 1. In iCal create an event (note the date-time of the event).
    > 2. Quit iCal and In System Preferences change the timezone (different
    > continent preferably)
    > 3. Launch iCal again and note the date-time of the event. It will be
    > different and it is correct because the date-time is adjusted based on the
    > timezone.
    > 4. Now change the timezone back to the original timezone.
    > 5. Quit and launch iCal.
    > 5. In iCal preferences (Advanced) check the "Turn on time zone support".
    > 6. Edit the iCal event and set the timezone to "Floating" (In the Info
    > drawer of the event).
    > 7. Quit iCal.
    > 8. Change the timezone in the System Preferences and run iCal. The
    > date-time is the same as the original date-time (that is it is not adjusted
    > based on the time zone).
    >
    > Sorry I couldn't explain it better before without an example application
    > doing the same. Any suggestions on how to implement this feature? Thank you.
    >
    > Regards
    > Sarat
    >
    > On 10/9/06, Shawn Erickson <shawnce...> wrote:
    >>
    >> On Oct 9, 2006, at 2:09 PM, Sarat Kongara wrote:
    >>
    >>> Thanks Shawn. I understand the NSDate behaviour better now. I guess
    >>> the best option for me is to save the Timezone with the dates so I can
    >>> adjust them on load or save the components individually
    >>> (mm,dd,yyyy,hh,mm,ss).
    >>
    >> I still don't understand what your issue is. The NSDate you save is
    >> the same one you get back when you load what you saved (same in the
    >> sense that it represents the same exact time). You should have no
    >> need to adjust anything.
    >>
    >> Can you better describe the problem you are trying to solve?
    >>
    >> -Shawn
    >>
    >
    >
previous month october 2006 next month
MTWTFSS
            1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31          
Go to today