Last active
September 10, 2015 01:47
-
-
Save bruxisma/714e7396bca290c2e6ef to your computer and use it in GitHub Desktop.
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 <iostream> | |
#include <chrono> | |
#include <ctime> | |
using ::std::cout; | |
using ::std::endl; | |
namespace time { | |
using ::std::chrono::system_clock; | |
int now () noexcept { | |
auto tm = system_clock::to_time_t(system_clock::now()); | |
auto utc = ::std::gmtime(&tm); | |
if (not utc) { return -1; } | |
auto date = *utc; | |
date.tm_hour += 1; | |
auto sum = date.tm_sec + date.tm_min * 60 + date.tm_hour * 3600; | |
return sum / 86.4; | |
} | |
} /* namespace time */ | |
int main () { cout << "Current Internet Time: @" << time::now() << endl; } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment