• Robert Sprowson's avatar
    Make mktime() correct for local time. · 27bebb79
    Robert Sprowson authored
    Following an earlier fix, the logic of mktime() has turned out to need reviewing too.
    To summarise
      time() -> a UTC time in seconds
      gmtime() -> breaks down a UTC time into components
      localtime() -> breaks down a UTC time into local components (tz + DST)
      mktime() -> converts local components back into UTC time, normalising
    In mktime(), the current locale (via setlocale()) is considered and used to choose the timezone, assuming an appropriate territory module is loaded.
    The value of the tm_isdst field is factored into the offset calculation.
    However, mktime() is also defined as normalising the components of time and updating the caller's block with normalised values, in local time, so the local offset is reapplied at the end.
    
    Moved time_to_tm up in the function so mktime() can use it.
    Corrected/lined up some comments.
    Also, mktime() no longer forces tm_isdst to -1, it preserves the user's value, so consecutive mktime()s are consistent.
    Added test to "test/tzones.c", results compared with Windows XP.
    
    Version 5.69. Tagged as 'RISC_OSLib-5_69'
    27bebb79
Name
Last commit
Last update
..
!TboxCalc Loading commit data...
c Loading commit data...
s Loading commit data...