Merge pull request #71 from johnslemmer/fixes

Fixes for #69 #70
pull/78/head
Rop Gonggrijp 6 years ago committed by GitHub
commit ddb5c4575b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -749,9 +749,7 @@ time_t Timezone::tzTime(time_t t, ezLocalOrUTC_t local_or_utc, String &tzname, b
if (tzname == "UTC" && std_offset) tzname = "???"; if (tzname == "UTC" && std_offset) tzname = "???";
is_dst = false; is_dst = false;
offset = std_offset; offset = std_offset;
return t - std_offset * 60; } else {
}
int16_t dst_offset = std_offset - dst_shift_hr * 60 - dst_shift_min; int16_t dst_offset = std_offset - dst_shift_hr * 60 - dst_shift_min;
// to find the year // to find the year
tmElements_t tm; tmElements_t tm;
@ -778,6 +776,7 @@ time_t Timezone::tzTime(time_t t, ezLocalOrUTC_t local_or_utc, String &tzname, b
} else { } else {
offset = std_offset; offset = std_offset;
} }
}
if (local_or_utc == LOCAL_TIME) { if (local_or_utc == LOCAL_TIME) {
return t + offset * 60LL; return t + offset * 60LL;
@ -1184,7 +1183,18 @@ String Timezone::dateTime(time_t t, const ezLocalOrUTC_t local_or_utc, const Str
String tzname; String tzname;
bool is_dst; bool is_dst;
int16_t offset; int16_t offset;
t = tzTime(t, LOCAL_TIME, tzname, is_dst, offset);
if (t == TIME_NOW || t == LAST_READ || local_or_utc == UTC_TIME) {
// in these cases we actually want tzTime to translate the time for us
// back in to this timezone's time as well as grab the timezone info
// from the stored POSIX data
t = tzTime(t, UTC_TIME, tzname, is_dst, offset);
} else {
// when receiving a local time we don't want to translate the timestamp
// but rather use tzTime to just parse the info about the timezone from
// the stored POSIX data
tzTime(t, LOCAL_TIME, tzname, is_dst, offset);
}
String tmpstr; String tmpstr;
uint8_t tmpint8; uint8_t tmpint8;

Loading…
Cancel
Save