-
-
Notifications
You must be signed in to change notification settings - Fork 181
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rework gigasecond to be slightly more challenging (#925)
* Rework gigasecond to be slightly more challenging * clang-format * review suggestions
- Loading branch information
Showing
6 changed files
with
41 additions
and
22 deletions.
There are no files selected for viewing
This file contains 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 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,7 @@ | ||
## Use UTC | ||
|
||
To solve this problem, you'll need to convert a `time_t` value into a `struct tm` value. | ||
The [`time.h`][time.h] library gives you two functions to do this. | ||
Make sure you use the one that results in a calendar time expressed in **UTC**. | ||
|
||
[time.h]: https://en.cppreference.com/w/c/chrono |
This file contains 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 |
---|---|---|
@@ -1,6 +1,10 @@ | ||
#include "gigasecond.h" | ||
|
||
time_t gigasecond_after(time_t start) | ||
#define GIGASECOND 1000000000 | ||
|
||
void gigasecond(time_t start, char *buffer, size_t size) | ||
{ | ||
return start + 1000000000; | ||
time_t after = start + GIGASECOND; | ||
struct tm *t = gmtime(&after); | ||
strftime(buffer, size, "%Y-%m-%d %H:%M:%S", t); | ||
} |
This file contains 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 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 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