Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
15ce8eb4
Commit
15ce8eb4
authored
Dec 16, 2019
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
time/ISO8601: support omitting field separators
Closes
https://github.com/MusicPlayerDaemon/MPD/issues/685
parent
b7744be2
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
4 deletions
+23
-4
NEWS
NEWS
+2
-2
ISO8601.cxx
src/time/ISO8601.cxx
+12
-2
TestISO8601.cxx
test/TestISO8601.cxx
+9
-0
No files found.
NEWS
View file @
15ce8eb4
ver 0.21.17 (not yet released)
* protocol
- relax the ISO 8601 parser: allow omitting
the time of day and the "Z"
suffix
- relax the ISO 8601 parser: allow omitting
field separators, the
time of day and the "Z"
suffix
* archive
- zzip: improve error reporting
* outputs
...
...
src/time/ISO8601.cxx
View file @
15ce8eb4
...
...
@@ -123,8 +123,12 @@ ParseISO8601(const char *s)
/* parse the date */
const
char
*
end
=
strptime
(
s
,
"%F"
,
&
tm
);
if
(
end
==
nullptr
)
throw
std
::
runtime_error
(
"Failed to parse date"
);
if
(
end
==
nullptr
)
{
/* try without field separators */
end
=
strptime
(
s
,
"%Y%m%d"
,
&
tm
);
if
(
end
==
nullptr
)
throw
std
::
runtime_error
(
"Failed to parse date"
);
}
s
=
end
;
...
...
@@ -136,6 +140,12 @@ ParseISO8601(const char *s)
if
((
end
=
strptime
(
s
,
"%T"
,
&
tm
))
!=
nullptr
)
precision
=
std
::
chrono
::
seconds
(
1
);
else
if
((
end
=
strptime
(
s
,
"%H%M%S"
,
&
tm
))
!=
nullptr
)
/* no field separators */
precision
=
std
::
chrono
::
seconds
(
1
);
else
if
((
end
=
strptime
(
s
,
"%H%M"
,
&
tm
))
!=
nullptr
)
/* no field separators */
precision
=
std
::
chrono
::
minutes
(
1
);
else
if
((
end
=
strptime
(
s
,
"%H:%M"
,
&
tm
))
!=
nullptr
)
precision
=
std
::
chrono
::
minutes
(
1
);
else
if
((
end
=
strptime
(
s
,
"%H"
,
&
tm
))
!=
nullptr
)
...
...
test/TestISO8601.cxx
View file @
15ce8eb4
...
...
@@ -71,6 +71,15 @@ static constexpr struct {
{
"2019-02-04T16:46:41+0200"
,
1549291601
,
std
::
chrono
::
seconds
(
1
)
},
{
"2019-02-04T16:46:41+02:00"
,
1549291601
,
std
::
chrono
::
seconds
(
1
)
},
{
"2019-02-04T16:46:41-0200"
,
1549306001
,
std
::
chrono
::
seconds
(
1
)
},
/* without field separators */
{
"19700101T000000Z"
,
0
,
std
::
chrono
::
seconds
(
1
)
},
{
"19700101T000001Z"
,
1
,
std
::
chrono
::
seconds
(
1
)
},
{
"20190204T164641Z"
,
1549298801
,
std
::
chrono
::
seconds
(
1
)
},
{
"19700101"
,
0
,
std
::
chrono
::
hours
(
24
)
},
{
"20190204"
,
1549238400
,
std
::
chrono
::
hours
(
24
)
},
{
"20190204T1646"
,
1549298760
,
std
::
chrono
::
minutes
(
1
)
},
{
"20190204T16"
,
1549296000
,
std
::
chrono
::
hours
(
1
)
},
};
TEST
(
ISO8601
,
Parse
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment