Thread: how do I practically use the tm_isdst flag in the localtime function - C

  1. #1
    Registered User
    Join Date
    Jun 2010
    Posts
    7

    how do I practically use the tm_isdst flag in the localtime function - C

    I know this may be very simple but I am having difficulty using the tm_isdst flag inside the localtime function inside time.h

    When calling the localtime function, a flag is set. The flag is tm_isdst.
    The flag is 1 if daylight savings time is in effect and 0 when it is not.
    I understand that part, but when I attempt to use it, the compiler tells me it is undeclared. for example:

    if(tm_isdst == 1)
    hour = hour + 1; // meaning I want to add an hour to the time if the flag is set

    Am I implementing this correctly?

  2. #2
    Registered User
    Join Date
    Jun 2011
    Posts
    4,513
    "tm" is a structure declared in "time.h". "tm_isdst" is a member of that structure. Your code example does not show accessing the member of a struct (dot or arrow operator after the structure name).

    [edit]

    Quote Originally Posted by $ingh
    The flag is 1 if daylight savings time is in effect and 0 when it is not.
    Quote Originally Posted by C standard draft
    The value of tm_isdst is positive if Daylight Saving Time is in effect, zero if Daylight
    Saving Time is not in effect, and negative if the information is not available.
    Last edited by Matticus; 03-14-2014 at 07:55 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Let's talk practically about pointers
    By Cevris in forum C Programming
    Replies: 23
    Last Post: 04-24-2011, 06:20 AM
  2. localtime curiosity
    By rjhanby in forum C Programming
    Replies: 5
    Last Post: 03-20-2009, 10:15 AM
  3. localtime
    By cnu_sree in forum C Programming
    Replies: 1
    Last Post: 06-06-2007, 11:19 PM
  4. localtime and time
    By l2u in forum C Programming
    Replies: 5
    Last Post: 07-24-2006, 12:10 PM
  5. getting LocalTime
    By Devil Panther in forum Windows Programming
    Replies: 2
    Last Post: 06-20-2003, 05:41 AM

Tags for this Thread