diff options
| author | mio <stigma@disroot.org> | 2025-03-08 19:53:55 +1000 |
|---|---|---|
| committer | mio <stigma@disroot.org> | 2025-03-10 09:13:10 +1000 |
| commit | 7d3bf3e611cf7638426b69564ba1786c307893fb (patch) | |
| tree | 4dcd4af0ee5e9b55abcb05714125577b641a27f7 /tdecore/krfcdate.cpp | |
| parent | 0418e523c6365efea9aca1811cb92b830752e76e (diff) | |
| download | tdelibs-7d3bf3e6.tar.gz tdelibs-7d3bf3e6.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>
(cherry picked from commit b56e68eac7a8e916a905e5f8ebe058907340128b)
Diffstat (limited to 'tdecore/krfcdate.cpp')
| -rw-r--r-- | tdecore/krfcdate.cpp | 10 |
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); |
