File tree Expand file tree Collapse file tree 1 file changed +21
-2
lines changed Expand file tree Collapse file tree 1 file changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -102,8 +102,27 @@ class Time {
102
102
*/
103
103
unsigned long getUNIXTimestamp () {
104
104
// Simple conversion to UNIX timestamp, not accounting for leap years or time zones
105
- unsigned long timestamp = second + minute*60 + hour*3600 + day*86400 + (month-1 )*2629743 + (year-1970 )*31556926 ;
106
- return timestamp;
105
+ struct tm t =
106
+ {
107
+ 0 /* tm_sec */ ,
108
+ 0 /* tm_min */ ,
109
+ 0 /* tm_hour */ ,
110
+ 0 /* tm_mday */ ,
111
+ 0 /* tm_mon */ ,
112
+ 0 /* tm_year */ ,
113
+ 0 /* tm_wday */ ,
114
+ 0 /* tm_yday */ ,
115
+ 0 /* tm_isdst */
116
+ };
117
+ t.tm_mon = month-1 ;
118
+ t.tm_mday = day;
119
+ t.tm_year = year - 1900 ;
120
+ t.tm_hour = hour;
121
+ t.tm_min = minute;
122
+ t.tm_sec = second;
123
+ t.tm_isdst = -1 ;
124
+
125
+ return mktime (&t);
107
126
}
108
127
109
128
/* *
You can’t perform that action at this time.
0 commit comments