get-universal-time-ms added

This commit is contained in:
vaclavt
2022-05-27 17:34:57 +02:00
parent 8e142dc7ea
commit fb552633c2
5 changed files with 32 additions and 5 deletions

View File

@@ -2,6 +2,7 @@
#include "ml_date.h"
#include <cstring>
#include <stdexcept>
#include <chrono>
long now() { // get-universal-time
time_t t = std::time(nullptr);
@@ -10,6 +11,13 @@ long now() { // get-universal-time
return now;
}
long now_ms() { // get-universal-time-ms
using namespace std::chrono;
milliseconds ms = duration_cast< milliseconds >(system_clock::now().time_since_epoch());
return ms.count();
}
long get_gmt_localtime_offset() {
std::time_t current_time;
std::time(&current_time);