KF5: Parsing times with timezone abbreviations
kevin.kofler at chello.at
Mon Mar 24 03:33:34 GMT 2014
what is the recommended way to parse times with short timezone
abbreviations, such as "16:00 CET", in Qt 5 / KF5 land? (I am asking because
this is the format the BBC is using for weather observation times in their
In kdelibs 4, this should do what we want:
dateTime = KDateTime::fromString(timeString, "%H:%M %Z").toLocalZone().dateTime();
but KDateTime is deprecated in KF5.
I looked at:
* QDateTime, but neither of the 2 QDateTime::fromString overloads in Qt 5.2
support the needed format, at least according to the documentation. The
one that takes a string does not support time zones (or so the
documentation says), the one that takes an enum entry does not support the
required format either.
* QTimeZone, but I cannot find a straightforward (documented) way to get a
QTimeZone from only the short abbreviation. I guess one could go through
all the availableTimeZoneIds and checking if the abbreviation matches, but
that won't necessarily give the expected (most probable) result
(especially if the abbreviation is not unique), will it?
More information about the kde-core-devel