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

Hinweis: der ursprüngliche Beitrag ist mehr als 6 Monate alt. Bitte hier nur auf die ursprüngliche Frage antworten, für neue Fragen einen neuen Beitrag erstellen.

Formatierung
  • [c]C-Code[/c]
  • [code]Code in anderen Sprachen, ASCII-Zeichnungen[/code]
  • [math]Formel in LaTeX-Syntax[/math]
  • [[Titel]] – Link zu einem Artikel
  • Verweis auf einen anderen Beitrag: Rechtsklick auf dessen Beitrags-ID (#8078628), „Adresse kopieren“, in den Text einfügen

Mehr zur Formatierung

Längeren Sourcecode als Anhang, nicht in den Text. JPG nur für Fotos und Scans; Zeichnungen und Screenshots als PNG oder GIF. Siehe Bildformate.

Schon registriert? Anmelden

Wird nicht angezeigt. Wir schicken dir einen Link; sobald du damit bestätigst, erscheint dein Beitrag.

Mit dem Abschicken legst du einen kostenlosen Account an und erkennst die Nutzungsbedingungen und die Datenschutzerklärung an.