Which UTC offset does Qt pick for ambiguous local times during DST fall‑back across platforms?
0 reputation · 17 Sept 2022, 16:23 UTC
0 reputation · 17 Sept 2022, 16:23 UTC
When a local wall‑clock time occurs twice during the fall‑back transition, Qt must decide which UTC offset to apply. The default is to use the earlier offset, but this choice is not formally guaranteed across operating systems or future Qt releases. Unix‑like hosts query the IANA time‑zone database while Windows historically consults the system registry, so the same zone identifier can resolve differently.
Because Qt does not bundle its own time‑zone data, an application’s conversions can change after an OS update without any code modification. Developers need to know whether the chosen offset is stable enough for round‑trip conversions and for cross‑platform deployments.
Which UTC offset does Qt select for a given ambiguous local time on Windows versus Unix? Does Qt guarantee that a round‑trip conversion preserves the original instant for ambiguous times across all supported Qt releases? Can developers explicitly query the chosen offset before performing conversions, or must they rely on the default resolution?
Qt selects the earlier (DST) offset for ambiguous local times during the fall‑back transition on both Windows and Unix‑like systems.
When constructing a QDateTime from a wall‑clock string that maps to two possible UTC instants, Qt queries the underlying OS time‑zone database (IANA on Unix, Windows registry on Windows). Both sources return the two possible offsets in chronological order; Qt takes the first offset it receives, which corresponds to the DST offset (the larger positive offset from UTC).
QDateTime dt(QStringLiteral("2026-10-26 01:30:00"), QTimeZone(QStringLiteral("Europe/Berlin")));dt.offsetFromUtc() or dt.toUtc().toString(Qt::ISODate).If you need to know whether the observed offset matches your expectation for a specific Qt version or OS tzdata release, please provide that version information so the recommendation can be adjusted.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.