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
d7dbf47a
Commit
d7dbf47a
authored
Sep 02, 2019
by
Max Kellermann
Committed by
Max Kellermann
Sep 25, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
time/ISO8601: support omitting minutes
parent
3db584a3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
0 deletions
+6
-0
ISO8601.cxx
src/time/ISO8601.cxx
+2
-0
TestISO8601.cxx
test/TestISO8601.cxx
+4
-0
No files found.
src/time/ISO8601.cxx
View file @
d7dbf47a
...
@@ -138,6 +138,8 @@ ParseISO8601(const char *s)
...
@@ -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"
);
...
...
test/TestISO8601.cxx
View file @
d7dbf47a
...
@@ -62,6 +62,10 @@ static constexpr struct {
...
@@ -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
)
},
...
...
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