mktime( 16:00:60 ) -> 17:01:00?

Gast #6700601
Lesenswert?

Wenn ich zu einer struct tm 60 Sekunden addiere und mktime aufrufe, wird 
auch die Stunde inkrementiert - warum?

    Sat May 22 16:00:00 2021
    tm_sec += 60;
    Sat May 22 16:00:60 2021
    mktime()
    Sat May 22 17:01:00 2021

.platformio\packages\framework-arduinoespressif8266\tools\sdk\libc\xtens 
a-lx106-elf\include\time.h

https://www.cplusplus.com/reference/ctime/mktime/
Moderator Persönliche Seite #6700610
Lesenswert?

Mein Manual sagt:

"The functions mktime() and timegm() convert the broken-down time in the 
structure pointed to by tm into a time value with the same encoding as 
that of the values returned by the time(3) function (that is, seconds 
from the Epoch, UTC).[…]

The original values of the tm_wday and tm_yday components of the 
structure are ignored, and the original values of the other components 
are not restricted to their normal ranges, and will be normalized if 
needed. […]"

Das ist also ein Feature.
Gast #6700628
Lesenswert?

Jörg W. schrieb:
> will be normalized if needed

Das versuche ich ja auszunutzen, allerdings nutzt die Funktion auch die 
lokale Zeitzone, und die ist hier gerade DST - daher kommt die eine 
Stunde Differenz.

Nun sind die auf SO vorgeschlagenen Lösungen (lokale Zeit auf UTC 
stellen, andere Funktionen, Bibliotheken) für Linux.
Ich suche also weiter...

Antwort schreiben

Bitte melde dich an, um einen Beitrag zu schreiben.

oder

Mit Google-Account einloggen

Die Registrierung ist kostenlos und dauert nur eine Minute.

Jetzt registrieren