-
Notifications
You must be signed in to change notification settings - Fork 247
Time point parsing bounds #7648
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
eddyashton
wants to merge
19
commits into
microsoft:main
Choose a base branch
from
eddyashton:time_point_parsing_bounds
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+219
−26
Open
Changes from 8 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
9e9e27f
Test parsing of edge-of-bounds time points
eddyashton aba6a88
More crypto test
eddyashton b6b08a7
Separate seconds-since-epoch calculation from conversion to system_clock
eddyashton f5aae5f
Prefer since_epoch_from_string to time_point_from_string
eddyashton 66f674b
Add e2e tests of far-future certs
eddyashton 1c88432
Format
eddyashton 4bb5378
Try a new Clock type, to minimise other diffs
eddyashton 8665607
Docs and format
eddyashton 6a0c740
Rename
eddyashton cc7dd1b
CHANGELOG
eddyashton f9acac1
e2e test of representable range
eddyashton f787145
Robot
eddyashton 3bd9db2
Good robot
eddyashton e9c9aae
Robot suggestion: avoid conversion to sys_days
eddyashton 2fa5d8c
Robot: Fix conversion from strange formats, add tests
eddyashton 9782dda
The robot giveth, the robot taketh away
eddyashton 623a3f0
Merge branch 'main' into time_point_parsing_bounds
achamayou 0897fbd
Merge branch 'main' into time_point_parsing_bounds
achamayou 70e5a5c
fmt
achamayou File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the Apache 2.0 License. | ||
| #pragma once | ||
|
|
||
| #include <chrono> | ||
|
|
||
| namespace ccf::ds | ||
| { | ||
| // A custom clock type for handling certificate validity periods, which are | ||
| // defined in terms of seconds since the epoch. This avoids issues with | ||
| // system_clock::time_point being unable to represent times after 2262-04-11 | ||
| // 23:47:17 UTC (due to tracking nanosecond precision). | ||
| struct EpochClock | ||
| { | ||
| using duration = std::chrono::seconds; | ||
| using rep = duration::rep; | ||
| using period = duration::period; | ||
| using time_point = std::chrono::time_point<EpochClock>; | ||
| static constexpr bool is_steady = false; | ||
|
|
||
| static time_point now() noexcept | ||
| { | ||
| return time_point(duration(std::time(nullptr))); | ||
| } | ||
eddyashton marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| static std::time_t to_time_t(const time_point& t) noexcept | ||
| { | ||
| return std::time_t(t.time_since_epoch().count()); | ||
| } | ||
|
|
||
| static time_point from_time_t(std::time_t t) noexcept | ||
| { | ||
| return time_point(duration(t)); | ||
| } | ||
| }; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.