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
9fc3c609
Commit
9fc3c609
authored
Aug 10, 2021
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
time/FileTime: add FileTimeToChronoDuration()
parent
1976003e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
1 deletion
+20
-1
FileTime.hxx
src/time/FileTime.hxx
+20
-1
No files found.
src/time/FileTime.hxx
View file @
9fc3c609
...
...
@@ -53,6 +53,24 @@ ToInt64(FILETIME ft) noexcept
return
ToUint64
(
ft
);
}
/* "A file time is a 64-bit value that represents the number of
100-nanosecond intervals"
https://docs.microsoft.com/en-us/windows/win32/sysinfo/file-times */
using
FileTimeResolution
=
std
::
ratio
<
1
,
10000000
>
;
using
FileTimeDuration
=
std
::
chrono
::
duration
<
int_least64_t
,
FileTimeResolution
>
;
/**
* Calculate a std::chrono::duration specifying the duration of the
* FILETIME since its epoch (1601-01-01T00:00).
*/
constexpr
auto
FileTimeToChronoDuration
(
FILETIME
ft
)
noexcept
{
return
FileTimeDuration
(
ToInt64
(
ft
));
}
constexpr
time_t
FileTimeToTimeT
(
FILETIME
ft
)
noexcept
{
...
...
@@ -69,7 +87,8 @@ FileTimeToChrono(FILETIME ft) noexcept
constexpr
std
::
chrono
::
seconds
DeltaFileTimeS
(
FILETIME
a
,
FILETIME
b
)
noexcept
{
return
std
::
chrono
::
seconds
((
ToInt64
(
a
)
-
ToInt64
(
b
))
/
10000000
);
return
std
::
chrono
::
duration_cast
<
std
::
chrono
::
seconds
>
(
FileTimeToChronoDuration
(
a
)
-
FileTimeToChronoDuration
(
b
));
}
#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