summaryrefslogtreecommitdiffstats
path: root/tdecore/krfcdate.cpp
diff options
context:
space:
mode:
authormio <stigma@disroot.org>2025-03-08 19:53:55 +1000
committermio <stigma@disroot.org>2025-03-10 08:28:51 +1000
commitb56e68eac7a8e916a905e5f8ebe058907340128b (patch)
tree7efe67796ab5605b07add73c02b3da0c1c73bf96 /tdecore/krfcdate.cpp
parentc4b62f2d49bcbc717ea7030ab75da69fe2016548 (diff)
downloadtdelibs-b56e68eac7a8e916a905e5f8ebe058907340128b.tar.gz
tdelibs-b56e68eac7a8e916a905e5f8ebe058907340128b.zip
KRFCDate minutes/seconds can be omitted (ISO8601)
ISO 8601 allows for dates and times to be represented with "reduced precision". In the case of times, this means the minutes and seconds can be omitted. More automated tests have been enabled, with the remaining ones to be fixed up in a later PR. Signed-off-by: mio <stigma@disroot.org>
Diffstat (limited to 'tdecore/krfcdate.cpp')
-rw-r--r--tdecore/krfcdate.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/tdecore/krfcdate.cpp b/tdecore/krfcdate.cpp
index 327736b40..08691fd15 100644
--- a/tdecore/krfcdate.cpp
+++ b/tdecore/krfcdate.cpp
@@ -431,12 +431,16 @@ KRFCDate::parseDateISO8601( const TQString& input_ )
l = TQStringList::split(':', timeString);
- if (l.size() < 3)
+ // If the 'T' separator was included, there must at least
+ // be the hour, if not then it is invalid.
+ if (l.size() < 1)
return 0;
hour = l[0].toUInt();
- min = l[1].toUInt();
- sec = l[2].toUInt();
+
+ // Minutes and seconds can be omitted.
+ min = (l.size() >= 2) ? l[1].toUInt() : 0;
+ sec = (l.size() >= 3) ? l[2].toUInt() : 0;
time_t result = ymdhms_to_seconds(year, month, mday, hour, min, sec);