Skip to content

Instantly share code, notes, and snippets.

@utilForever
Created June 16, 2019 07:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save utilForever/5ea68e37795a86986ebfb6b6ebdf7021 to your computer and use it in GitHub Desktop.
Save utilForever/5ea68e37795a86986ebfb6b6ebdf7021 to your computer and use it in GitHub Desktop.
Comparison between localtime_r and localtime_s
#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