comparison libpurple/util.c @ 22896:8dadddab10ed

Fix purple_str_to_time() to not break the returned value when we have given it a string with a GMT offset (like a log filename). We were setting tm_isdst to 0 when we knew the offset. Apparently, mktime() said, "Umm, yes, it is DST." and fixed it by shifting the hour. The fix is to tell the C library (by setting tm_isdst to -1) that we're sure of the time, but not the DST status. Hopefully this doesn't break any other code path. Fixes #3550
author Richard Laager <rlaager@wiktel.com>
date Sun, 11 May 2008 04:50:36 +0000
parents 7d4fcb142572
children dea8b856466e
comparison
equal deleted inserted replaced
22895:0bd86dae2734 22896:8dadddab10ed
829 (sscanf(c, "%02d%02d", &tzhrs, &tzmins) == 2 && (c = c + 4)))) 829 (sscanf(c, "%02d%02d", &tzhrs, &tzmins) == 2 && (c = c + 4))))
830 { 830 {
831 tzoff = tzhrs*60*60 + tzmins*60; 831 tzoff = tzhrs*60*60 + tzmins*60;
832 if (offset_positive) 832 if (offset_positive)
833 tzoff *= -1; 833 tzoff *= -1;
834 /* We don't want the C library doing DST calculations
835 * if we know the UTC offset already. */
836 t.tm_isdst = 0;
837 } 834 }
838 else if (utc) 835 else if (utc)
839 { 836 {
840 static struct tm tmptm; 837 static struct tm tmptm;
841 time_t tmp; 838 time_t tmp;
893 if (rest != NULL && *c != '\0') 890 if (rest != NULL && *c != '\0')
894 *rest = c; 891 *rest = c;
895 } 892 }
896 } 893 }
897 894
895 retval = mktime(&t);
896
898 if (tm != NULL) 897 if (tm != NULL)
899 {
900 *tm = t; 898 *tm = t;
901 tm->tm_isdst = -1; 899
902 mktime(tm);
903 }
904
905 retval = mktime(&t);
906 if (tzoff != PURPLE_NO_TZ_OFF) 900 if (tzoff != PURPLE_NO_TZ_OFF)
907 retval += tzoff; 901 retval += tzoff;
908 902
909 if (tz_off != NULL) 903 if (tz_off != NULL)
910 *tz_off = tzoff; 904 *tz_off = tzoff;