Created
June 16, 2019 07:39
-
-
Save utilForever/5ea68e37795a86986ebfb6b6ebdf7021 to your computer and use it in GitHub Desktop.
Comparison between localtime_r and localtime_s
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
#include <ctime> | |
#include <iostream> | |
int is_morning_good() { | |
const time_t now_seconds = time(NULL); | |
struct tm now; | |
localtime_r(&now_seconds, &now); | |
return (now.tm_hour < 12); | |
} | |
int main() | |
{ | |
std::cout << is_morning_good(); | |
} | |
#include <ctime> | |
#include <iostream> | |
int is_morning_good() { | |
const time_t now_seconds = time(NULL); | |
struct tm now; | |
localtime_r(&now_seconds, &now); | |
return (now.tm_hour < 12); | |
} | |
int main() | |
{ | |
std::cout << is_morning_good(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment