#t and #f added to language, datetime fixes

This commit is contained in:
2021-10-12 13:26:38 +02:00
parent adca8a452b
commit 4359012190
13 changed files with 90 additions and 55 deletions

View File

@@ -8,6 +8,14 @@ long now() { // get-universal-time
return now;
}
long get_gmt_localtime_offset() {
std::time_t current_time;
std::time(&current_time);
struct std::tm *timeinfo = std::localtime(&current_time);
long offset = timeinfo->tm_gmtoff;
return offset;
}
std::string date_to_string(const long datetime, const std::string format) {
// std::locale::global(std::locale("en-US.UTF8"));
@@ -56,7 +64,7 @@ long string_to_date(const std::string &datestr, const std::string &format) {
struct tm * timeinfo;
time(&curTime );
timeinfo = localtime(&curTime);
timeinfo = std::gmtime(&curTime);
timeinfo->tm_year = tm.tm_year;
timeinfo->tm_mon = tm.tm_mon;
@@ -65,9 +73,7 @@ long string_to_date(const std::string &datestr, const std::string &format) {
timeinfo->tm_min = tm.tm_min;
timeinfo->tm_sec = tm.tm_sec;
// int offset = -1 * timeinfo->tm_gmtoff; // for local time
int offset = 0;
return time_to_epoch(timeinfo, offset);
return time_to_epoch(timeinfo, 0);
}
throw std::runtime_error("invalid date string or format (" + datestr + ", " + format + ")" );