Skip to content

Instantly share code, notes, and snippets.

@bruxisma
Last active September 10, 2015 01:47
Show Gist options
  • Save bruxisma/714e7396bca290c2e6ef to your computer and use it in GitHub Desktop.
Save bruxisma/714e7396bca290c2e6ef to your computer and use it in GitHub Desktop.
#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