fork download
  1. #include <iostream>
  2. #include <chrono>
  3. #include <limits>
  4. using namespace std;
  5.  
  6. namespace WTF {
  7.  
  8. using nanoseconds = std::chrono::duration<double, std::nano>;
  9. using microseconds = std::chrono::duration<double, std::micro>;
  10. using milliseconds = std::chrono::duration<double, std::milli>;
  11. using seconds = std::chrono::duration<double>;
  12. using minutes = std::chrono::duration<double, std::ratio<60>>;
  13. using hours = std::chrono::duration<double, std::ratio<3600>>;
  14.  
  15.  
  16. template <class Clock>
  17. std::chrono::time_point<Clock, seconds> now()
  18. {
  19. return Clock::now();
  20. }
  21.  
  22. }
  23.  
  24. namespace std {
  25. namespace chrono {
  26. template<>
  27. struct duration_values<double> {
  28. static constexpr double min() { return -std::numeric_limits<double>::infinity(); }
  29. static constexpr double zero() { return .0; }
  30. static constexpr double max() { return std::numeric_limits<double>::infinity(); }
  31. };
  32. }
  33. }
  34.  
  35.  
  36. int main() {
  37. std::cout << fixed << WTF::now<std::chrono::system_clock>().time_since_epoch().count() << std::endl;
  38. std::cout << fixed << WTF::now<std::chrono::system_clock>().time_since_epoch().count() << std::endl;
  39. return 0;
  40. }
Success #stdin #stdout 0s 3460KB
stdin
Standard input is empty
stdout
1463986095.335097
1463986095.335287