diff options
author | Max Kellermann <max@musicpd.org> | 2019-08-19 22:37:16 +0200 |
---|---|---|
committer | Max Kellermann <max@musicpd.org> | 2019-08-19 22:44:41 +0200 |
commit | f3ed2c0a825b4eb44245b7f108f2f292e666463b (patch) | |
tree | 305420894c04ccf77767f19433df0e173f5b382d /src/time | |
parent | 2c35ea92bd8e40ee66204e20b99f238effc4fc91 (diff) |
time/ISO8601: support omitting seconds
Diffstat (limited to 'src/time')
-rw-r--r-- | src/time/ISO8601.cxx | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/time/ISO8601.cxx b/src/time/ISO8601.cxx index 6671a8ca4..f4d0d5d38 100644 --- a/src/time/ISO8601.cxx +++ b/src/time/ISO8601.cxx @@ -133,12 +133,15 @@ ParseISO8601(const char *s) /* parse the time of day */ if (*s == 'T') { ++s; - end = strptime(s, "%T", &tm); - if (end == nullptr) + + if ((end = strptime(s, "%T", &tm)) != nullptr) + precision = std::chrono::seconds(1); + else if ((end = strptime(s, "%H:%M", &tm)) != nullptr) + precision = std::chrono::minutes(1); + else throw std::runtime_error("Failed to parse time of day"); s = end; - precision = std::chrono::seconds(1); } auto tp = TimeGm(tm); |