time/ISO8601: allow omitting the "Z" suffix
And allow "Z" suffix after date.
This commit is contained in:
parent
6412efb6e4
commit
26e0e1d25a
3
NEWS
3
NEWS
@ -3,7 +3,8 @@ ver 0.22 (not yet released)
|
|||||||
- "findadd"/"searchadd"/"searchaddpl" support the "sort" and
|
- "findadd"/"searchadd"/"searchaddpl" support the "sort" and
|
||||||
"window" parameters
|
"window" parameters
|
||||||
- add command "readpicture" to download embedded pictures
|
- add command "readpicture" to download embedded pictures
|
||||||
- relax the ISO 8601 parser: allow omitting the time of day
|
- relax the ISO 8601 parser: allow omitting the time of day and the "Z"
|
||||||
|
suffix
|
||||||
* tags
|
* tags
|
||||||
- new tags "Grouping" (for ID3 "TIT1") and "Work"
|
- new tags "Grouping" (for ID3 "TIT1") and "Work"
|
||||||
* input
|
* input
|
||||||
|
@ -83,7 +83,7 @@ ParseISO8601(const char *s)
|
|||||||
/* parse the time of day */
|
/* parse the time of day */
|
||||||
if (*s == 'T') {
|
if (*s == 'T') {
|
||||||
++s;
|
++s;
|
||||||
end = strptime(s, "%TZ", &tm);
|
end = strptime(s, "%T", &tm);
|
||||||
if (end == nullptr)
|
if (end == nullptr)
|
||||||
throw std::runtime_error("Failed to parse time of day");
|
throw std::runtime_error("Failed to parse time of day");
|
||||||
|
|
||||||
@ -93,6 +93,9 @@ ParseISO8601(const char *s)
|
|||||||
|
|
||||||
auto tp = TimeGm(tm);
|
auto tp = TimeGm(tm);
|
||||||
|
|
||||||
|
if (*s == 'Z')
|
||||||
|
++s;
|
||||||
|
|
||||||
if (*s != 0)
|
if (*s != 0)
|
||||||
throw std::runtime_error("Garbage at end of time stamp");
|
throw std::runtime_error("Garbage at end of time stamp");
|
||||||
|
|
||||||
|
@ -51,6 +51,12 @@ static constexpr struct {
|
|||||||
{ "2019-02-04", 1549238400, std::chrono::hours(24) },
|
{ "2019-02-04", 1549238400, std::chrono::hours(24) },
|
||||||
{ "2018-12-31", 1546214400, std::chrono::hours(24) },
|
{ "2018-12-31", 1546214400, std::chrono::hours(24) },
|
||||||
{ "2019-01-01", 1546300800, std::chrono::hours(24) },
|
{ "2019-01-01", 1546300800, std::chrono::hours(24) },
|
||||||
|
|
||||||
|
/* date with time zone */
|
||||||
|
{ "2019-02-04Z", 1549238400, std::chrono::hours(24) },
|
||||||
|
|
||||||
|
/* without time zone */
|
||||||
|
{ "2019-02-04T16:46:41", 1549298801, std::chrono::seconds(1) },
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST(ISO8601, Parse)
|
TEST(ISO8601, Parse)
|
||||||
|
Loading…
Reference in New Issue
Block a user