Converting Internet Date Without DST Messing It Up

Discussion in 'iOS Programming' started by newtoiphonesdk, May 27, 2013.

  1. newtoiphonesdk macrumors 6502a

    Joined:
    Jul 30, 2010
    #1
    Here is the issue. I have an app I have built in which localendar.com is used for the calendar of events. Localendar has no option to set timezones to DST, so events that are currently going on appear as:

    Wed, 05 Jun 2013 22:00:00 CST

    instead of:

    Wed, 05 Jun 2013 22:00:00 CDT

    The issue is that when I convert this string to an NSDate for sorting purposes, it moves the time forward one hour because it is now DST. So, instead of the result being 6/5/13 10:00 PM, it shows as 6/5/13 11:00 PM.

    What I am needing is a good way to parse this date so that it will show up as 10:00 PM now, and not mess anything up when DST ends later this year. Any suggestions?
     
  2. KoolStar macrumors demi-god

    KoolStar

    Joined:
    Oct 16, 2006
    Location:
    Kentucky
    #2
    Why not convert to NSDate and then check if it currently is DST and adjust the date accordingly?
     
  3. newtoiphonesdk thread starter macrumors 6502a

    Joined:
    Jul 30, 2010
    #3
    How do you check if it is currently DST where the user is?
     
  4. chown33 macrumors 604

    Joined:
    Aug 9, 2009
    #5
    See the NSTimeZone class reference.

    Also see the Date and Time Programming Guide.
     
  5. newtoiphonesdk thread starter macrumors 6502a

    Joined:
    Jul 30, 2010
    #6
    Is asking a question on two different sites not allowed?

    ----------

    I know how to check if a specific NSDate is listed as DST, is it much different to find out if the system wide time is currently DST?
     
  6. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #7
    To quote fellow member PhoneyDeveloper (from another thread), with a slight edit:
     
  7. chown33 macrumors 604

    Joined:
    Aug 9, 2009
    #8
    Exactly how would you do that? Post your code.

    I don't think you actually read the NSTimeZone class reference, or even looked at it. If you had, or if you had simply visited the online web page and then searched for "daylight" on the page, the answer would have been as clear as, well, daylight.

    Another keyword to search for in the NSTimeZone class reference is "system", as in "system time zone". Also find "local", as in "local time zone".

    If, after reading the NSTimeZone class reference, you have a specific question that isn't answered in the class reference, then please ask it. If you haven't read the NSTimeZone class reference, then do that first.
     

Share This Page