Re: subtracting days from localtime problem

From: Andrey Simonenko (simon_at_comsys.ntu-kpi.kiev.ua)
Date: 03/31/05

  • Next message: Christoph Hellwig: "Re: organization"
    Date: Thu, 31 Mar 2005 16:47:42 +0300
    To: Ganbold <ganbold@micom.mng.net>
    
    

    On Thu, Mar 31, 2005 at 08:53:12PM +0900, Ganbold wrote:

    > I have problem subtracting days from current date using test program.
    > We have daylight saving occured on 2AM of March 26, 2005.
    > As you can see below, there is missing March 26th line from program output.
    > And all lines after 27th March are wrong.
    > Instead of 25th March it should be 26th March, 24th March should be 25th
    > March and so on.
    >
    > Can somebody tell me why is this happening? How can I correct this
    > problem?

    The problem is in tm_isdst field, which is 1, for current day
    March 31. You can see the problem in action, if you output not only
    date, but also time and tm_isdst for new date.

    To fix this problem set tm_isdst to -1 before mktime() function call,
    and again output date together with time and see difference. You can
    set tm_isdst to 0 and see the difference, and carefully read documentation
    for tm_isdst in SUSv3, for example.

    If you want to do such manipulations with time using standard
    library functions, then it will not be very easy, because of TZ
    changes, the problem you got is only one of many.

    ps: comp.unix.programmer would be a better place for such questions.
    _______________________________________________
    freebsd-hackers@freebsd.org mailing list
    http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
    To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org"


  • Next message: Christoph Hellwig: "Re: organization"

    Relevant Pages

    • Re: Unit Testing a API library
      ... Am I missing something? ... every possible input parameter value. ... what you are adding is forced upon you because the library functions ... would they be open to unit test style treatment? ...
      (comp.software.testing)
    • Re: Intel details future Larrabee graphics chip
      ... You're STILL missing the point! ... using in house library functions for embedded work for decades now and can't ... reliable and portable solution, especially if you restrict the code to a sub ansi ...
      (comp.arch)
    • Re: C99 conforming compilers
      ... Broken extended identifiers Missing library functions in Library Issue extended integer types in Missing additional math library functions in Library Issue Missing floating-point environment access in Library Issue IEC 60559 support Broken inline functions Broken additional predefined macro names Missing standard pragmas Missing deprecate ungetc at the beginning of a binary file Library Issue ...
      (comp.lang.c)
    • Re: mysql 4.0.17 fails to link on 5.0.7
      ... > mysql 4.0.17 compilation fails during link phase, ... It's hard to believe pthread_key_delete would be missing from the FSU ... library functions. ...
      (comp.unix.sco.misc)