time/ISO8601: support omitting minutes
This commit is contained in:
parent
d09bd9178f
commit
63c5d66016
@ -138,6 +138,8 @@ ParseISO8601(const char *s)
|
|||||||
precision = std::chrono::seconds(1);
|
precision = std::chrono::seconds(1);
|
||||||
else if ((end = strptime(s, "%H:%M", &tm)) != nullptr)
|
else if ((end = strptime(s, "%H:%M", &tm)) != nullptr)
|
||||||
precision = std::chrono::minutes(1);
|
precision = std::chrono::minutes(1);
|
||||||
|
else if ((end = strptime(s, "%H", &tm)) != nullptr)
|
||||||
|
precision = std::chrono::hours(1);
|
||||||
else
|
else
|
||||||
throw std::runtime_error("Failed to parse time of day");
|
throw std::runtime_error("Failed to parse time of day");
|
||||||
|
|
||||||
|
@ -62,6 +62,10 @@ static constexpr struct {
|
|||||||
{ "2019-02-04T16:46", 1549298760, std::chrono::minutes(1) },
|
{ "2019-02-04T16:46", 1549298760, std::chrono::minutes(1) },
|
||||||
{ "2019-02-04T16:46Z", 1549298760, std::chrono::minutes(1) },
|
{ "2019-02-04T16:46Z", 1549298760, std::chrono::minutes(1) },
|
||||||
|
|
||||||
|
/* without minutes */
|
||||||
|
{ "2019-02-04T16", 1549296000, std::chrono::hours(1) },
|
||||||
|
{ "2019-02-04T16Z", 1549296000, std::chrono::hours(1) },
|
||||||
|
|
||||||
/* with time zone */
|
/* with time zone */
|
||||||
{ "2019-02-04T16:46:41+02", 1549291601, std::chrono::seconds(1) },
|
{ "2019-02-04T16:46:41+02", 1549291601, std::chrono::seconds(1) },
|
||||||
{ "2019-02-04T16:46:41+0200", 1549291601, std::chrono::seconds(1) },
|
{ "2019-02-04T16:46:41+0200", 1549291601, std::chrono::seconds(1) },
|
||||||
|
Loading…
Reference in New Issue
Block a user