Thread: getting local time without daylight savings

  1. #1
    Registered User
    Join Date
    Jan 2005
    Posts
    108

    getting local time without daylight savings

    Is it possible to get localtime (or mktime) from time.h to get you the year day/hour/min/sec wthout the effects of daylight savings? That is, with only using the standard c library.. or anything cross platform..

  2. #2
    Registered User
    Join Date
    Jan 2005
    Posts
    108
    apologies, found the answer myself. DST shifts forward by one hour, so if tm_isdst is 1, then you just have to minus the tm_hour by one. I hope I'm right..

  3. #3
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    > DST shifts forward by one hour
    Not always an hour, but oh well. This is "overlooked" in the standard.

  4. #4
    Registered User
    Join Date
    Jan 2005
    Posts
    108
    Really? I hope it's not too common for it to be more than one hour..

    Is it possible to get just the timezone information then? curses to whoever invented DST..

    p.s g'day (or good night) to you mate, I'm from Australia as well

  5. #5
    Registered User
    Join Date
    Sep 2008
    Location
    Toronto, Canada
    Posts
    1,834
    I never realized it could be something other than one hour.
    Wow... since you're from Australia you might appreciate this...

    Clock shifts are usually scheduled near a weekend midnight to lessen disruption to weekday schedules. A one-hour shift is customary, but Australia's Lord Howe Island uses a half-hour shift.[25] Twenty-minute and two-hour shifts have been used in the past.
    ( Daylight saving time - Wikipedia, the free encyclopedia )

  6. #6
    Registered User
    Join Date
    Oct 2008
    Location
    TX
    Posts
    2,059
    Quote Originally Posted by underthesun View Post
    apologies, found the answer myself. DST shifts forward by one hour, so if tm_isdst is 1, then you just have to minus the tm_hour by one. I hope I'm right..
    That tm_isdst is just a flag, set if DST is in effect or cleared if it isn't. Here's what the man page has to say about it
    Code:
    The value of tm_isdst shall be positive if Daylight Savings Time is in effect, 
    0 if Daylight Savings Time is not in effect, and negative if the information is not available.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 26
    Last Post: 07-05-2010, 10:43 AM
  2. Local Time Program
    By Ronzel in forum C++ Programming
    Replies: 1
    Last Post: 06-18-2009, 07:19 AM
  3. How to get current time
    By tsubasa in forum C Programming
    Replies: 3
    Last Post: 05-01-2009, 02:03 AM
  4. A lesson in life kids: Bed time is for your own good!
    By Jeremy G in forum A Brief History of Cprogramming.com
    Replies: 18
    Last Post: 11-06-2003, 02:27 PM
  5. relating date....
    By Prakash in forum C Programming
    Replies: 3
    Last Post: 09-19-2001, 09:08 AM