#t and #f added to language, datetime fixes
This commit is contained in:
14
ml_date.cpp
14
ml_date.cpp
@@ -8,6 +8,14 @@ long now() { // get-universal-time
|
||||
return now;
|
||||
}
|
||||
|
||||
long get_gmt_localtime_offset() {
|
||||
std::time_t current_time;
|
||||
std::time(¤t_time);
|
||||
struct std::tm *timeinfo = std::localtime(¤t_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 + ")" );
|
||||
|
||||
Reference in New Issue
Block a user