|
@@ -926,28 +926,15 @@ typedef struct {
|
|
|
int offset;
|
|
|
} SDateTime;
|
|
|
|
|
|
+#ifdef __WIN32__
|
|
|
int bmx_calc_timeoffset_mins() {
|
|
|
- time_t rawtime;
|
|
|
- struct tm *local_tm, *utc_tm;
|
|
|
-
|
|
|
- time(&rawtime);
|
|
|
- local_tm = localtime(&rawtime);
|
|
|
- utc_tm = gmtime(&rawtime);
|
|
|
-
|
|
|
- // Calculate the time difference in minutes
|
|
|
- int diff_minutes = (local_tm->tm_hour - utc_tm->tm_hour) * 60 + (local_tm->tm_min - utc_tm->tm_min);
|
|
|
-
|
|
|
- // Adjust the difference if crossing a day boundary
|
|
|
- if (local_tm->tm_yday < utc_tm->tm_yday) {
|
|
|
- diff_minutes -= 24 * 60;
|
|
|
- } else if (local_tm->tm_yday > utc_tm->tm_yday) {
|
|
|
- diff_minutes += 24 * 60;
|
|
|
- }
|
|
|
-
|
|
|
- return diff_minutes;
|
|
|
+ TIME_ZONE_INFORMATION tz;
|
|
|
+ DWORD rc = GetTimeZoneInformation(&tz);
|
|
|
+ int offset_minutes = tz.Bias + (TIME_ZONE_ID_DAYLIGHT != rc ? tz.StandardBias : tz.DaylightBias);
|
|
|
+
|
|
|
+ return offset_minutes;
|
|
|
}
|
|
|
|
|
|
-#ifdef __WIN32__
|
|
|
void bmx_current_datetime(SDateTime * dt, int utc) {
|
|
|
SYSTEMTIME systemTime;
|
|
|
if (utc) {
|
|
@@ -967,6 +954,27 @@ void bmx_current_datetime(SDateTime * dt, int utc) {
|
|
|
dt->offset = utc ? 0 : bmx_calc_timeoffset_mins();
|
|
|
}
|
|
|
#else
|
|
|
+int bmx_calc_timeoffset_mins() {
|
|
|
+ time_t rawtime;
|
|
|
+ struct tm *local_tm, *utc_tm;
|
|
|
+
|
|
|
+ time(&rawtime);
|
|
|
+ local_tm = localtime(&rawtime);
|
|
|
+ utc_tm = gmtime(&rawtime);
|
|
|
+
|
|
|
+ // Calculate the time difference in minutes
|
|
|
+ int diff_minutes = (local_tm->tm_hour - utc_tm->tm_hour) * 60 + (local_tm->tm_min - utc_tm->tm_min);
|
|
|
+
|
|
|
+ // Adjust the difference if crossing a day boundary
|
|
|
+ if (local_tm->tm_yday < utc_tm->tm_yday) {
|
|
|
+ diff_minutes -= 24 * 60;
|
|
|
+ } else if (local_tm->tm_yday > utc_tm->tm_yday) {
|
|
|
+ diff_minutes += 24 * 60;
|
|
|
+ }
|
|
|
+
|
|
|
+ return diff_minutes;
|
|
|
+}
|
|
|
+
|
|
|
void bmx_current_datetime(SDateTime * dt, int utc) {
|
|
|
struct timespec ts;
|
|
|
struct tm *tm;
|