daylight saving time

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • bernhard Hoyler

    daylight saving time

    Hi,

    I would like to determine whether at a certain time point in time the
    daylight savings time is in effect. This means such a logic should show
    that today (16-Nov-2007) no daylight savings time (or European summertime)
    is in effect, but at 1-Aug-2007 it is.

    Thanks for your help

    Bernhard Hoyler


  • Victor Bazarov

    #2
    Re: daylight saving time

    bernhard Hoyler wrote:
    I would like to determine whether at a certain time point in time the
    daylight savings time is in effect. This means such a logic should
    show that today (16-Nov-2007) no daylight savings time (or European
    summertime) is in effect, but at 1-Aug-2007 it is.
    The simplest way would be to have our own table of correct values and
    compare against those ranges. You'd have to keep historical data since
    the laws about daylight saving were introduced in different places at
    different times. You also need to account for the place where the
    program is running since some locales don't support daylight saving
    times (like Arizona or parts of Indiana, IIRC). Also, the times at
    which DST goes in effect are different in different countries.

    OTOH you could of course rely on the member of the 'tm' struct, called
    tm_isdst. Google for it, I am sure there are example of how to use it.

    V
    --
    Please remove capital 'A's when replying by e-mail
    I do not respond to top-posted replies, please don't ask


    Comment

    • Juha Nieminen

      #3
      Re: daylight saving time

      Victor Bazarov wrote:
      bernhard Hoyler wrote:
      >I would like to determine whether at a certain time point in time the
      >daylight savings time is in effect. This means such a logic should
      >show that today (16-Nov-2007) no daylight savings time (or European
      >summertime) is in effect, but at 1-Aug-2007 it is.
      >
      The simplest way would be to have our own table of correct values and
      compare against those ranges.
      No, that's not the simplest way.

      The simplest way is to use std::time() and then std::localtime( ).
      The latter returns a struct tm, which contains the member variable
      tm_isdst which tells the info he is looking for.

      Unless my manpage is wrong, this should even be standard.

      CONFORMING TO
      SVr4, POSIX.1-2001, 4.3BSD, C89, C99.

      Comment

      • Victor Bazarov

        #4
        Re: daylight saving time

        Juha Nieminen wrote:
        Victor Bazarov wrote:
        >bernhard Hoyler wrote:
        >>I would like to determine whether at a certain time point in time
        >>the daylight savings time is in effect. This means such a logic
        >>should show that today (16-Nov-2007) no daylight savings time (or
        >>European summertime) is in effect, but at 1-Aug-2007 it is.
        >>
        >The simplest way would be to have our own table of correct values and
        >compare against those ranges.
        >
        No, that's not the simplest way.
        >
        The simplest way is to use std::time() and then std::localtime( ).
        The latter returns a struct tm, which contains the member variable
        tm_isdst which tells the info he is looking for.
        >
        Unless my manpage is wrong, this should even be standard.
        >
        CONFORMING TO
        SVr4, POSIX.1-2001, 4.3BSD, C89, C99.
        Are you sure that those functions and the struct provide the correct
        functionality for finding out, say, whether the WWI ended during DST
        or not? What if I enter the DOB of the Pope, will I know if he was
        born during European summertime?

        V
        --
        Please remove capital 'A's when replying by e-mail
        I do not respond to top-posted replies, please don't ask


        Comment

        Working...