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
5df2707d
Commit
5df2707d
authored
Aug 19, 2019
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
time/ISO8601: ParseISO8601() returns precision
parent
4859ea46
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
4 deletions
+19
-4
Filter.cxx
src/song/Filter.cxx
+1
-1
ISO8601.cxx
src/time/ISO8601.cxx
+7
-2
ISO8601.hxx
src/time/ISO8601.hxx
+11
-1
No files found.
src/song/Filter.cxx
View file @
5df2707d
...
...
@@ -120,7 +120,7 @@ ParseTimeStamp(const char *s)
return
std
::
chrono
::
system_clock
::
from_time_t
((
time_t
)
value
);
/* try ISO 8601 */
return
ParseISO8601
(
s
);
return
ParseISO8601
(
s
)
.
first
;
}
static
constexpr
bool
...
...
src/time/ISO8601.cxx
View file @
5df2707d
...
...
@@ -58,7 +58,8 @@ FormatISO8601(std::chrono::system_clock::time_point tp)
return
FormatISO8601
(
GmTime
(
tp
));
}
std
::
chrono
::
system_clock
::
time_point
std
::
pair
<
std
::
chrono
::
system_clock
::
time_point
,
std
::
chrono
::
system_clock
::
duration
>
ParseISO8601
(
const
char
*
s
)
{
assert
(
s
!=
nullptr
);
...
...
@@ -73,6 +74,10 @@ ParseISO8601(const char *s)
if
(
end
==
nullptr
||
*
end
!=
0
)
throw
std
::
runtime_error
(
"Failed to parse time stamp"
);
return
TimeGm
(
tm
);
std
::
chrono
::
system_clock
::
duration
precision
=
std
::
chrono
::
seconds
(
1
);
auto
tp
=
TimeGm
(
tm
);
return
std
::
make_pair
(
tp
,
precision
);
#endif
/* !_WIN32 */
}
src/time/ISO8601.hxx
View file @
5df2707d
...
...
@@ -36,6 +36,7 @@
#include "util/Compiler.h"
#include <chrono>
#include <utility>
#include <stddef.h>
...
...
@@ -50,7 +51,16 @@ gcc_pure
StringBuffer
<
64
>
FormatISO8601
(
std
::
chrono
::
system_clock
::
time_point
tp
);
std
::
chrono
::
system_clock
::
time_point
/**
* Parse a time stamp in ISO8601 format.
*
* Throws on error.
*
* @return a pair consisting of the time point and the specified
* precision; e.g. for a date, the second value is "one day"
*/
std
::
pair
<
std
::
chrono
::
system_clock
::
time_point
,
std
::
chrono
::
system_clock
::
duration
>
ParseISO8601
(
const
char
*
s
);
#endif
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