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
b0682582
Commit
b0682582
authored
Aug 19, 2019
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
time/ISO8601: allow omitting the "Z" suffix
And allow "Z" suffix after date.
parent
ba4cd47f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
2 deletions
+12
-2
NEWS
NEWS
+2
-1
ISO8601.cxx
src/time/ISO8601.cxx
+4
-1
TestISO8601.cxx
test/TestISO8601.cxx
+6
-0
No files found.
NEWS
View file @
b0682582
ver 0.21.17 (not yet released)
* protocol
- 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
* archive
- zzip: improve error reporting
* outputs
...
...
src/time/ISO8601.cxx
View file @
b0682582
...
...
@@ -83,7 +83,7 @@ ParseISO8601(const char *s)
/* parse the time of day */
if
(
*
s
==
'T'
)
{
++
s
;
end
=
strptime
(
s
,
"%T
Z
"
,
&
tm
);
end
=
strptime
(
s
,
"%T"
,
&
tm
);
if
(
end
==
nullptr
)
throw
std
::
runtime_error
(
"Failed to parse time of day"
);
...
...
@@ -93,6 +93,9 @@ ParseISO8601(const char *s)
auto
tp
=
TimeGm
(
tm
);
if
(
*
s
==
'Z'
)
++
s
;
if
(
*
s
!=
0
)
throw
std
::
runtime_error
(
"Garbage at end of time stamp"
);
...
...
test/TestISO8601.cxx
View file @
b0682582
...
...
@@ -51,6 +51,12 @@ static constexpr struct {
{
"2019-02-04"
,
1549238400
,
std
::
chrono
::
hours
(
24
)
},
{
"2018-12-31"
,
1546214400
,
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
)
...
...
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