X-Git-Url: http://git.marmaro.de/?a=blobdiff_plain;f=sbr%2Fdtime.c;h=acab87746a31e2729d5e64a0f9117b737d7c8d43;hb=bfad64befb4d6696fdfb63b119666eec4bac6fb3;hp=aa346216d274e009b13a86c8493808f02c3c85e3;hpb=3ef341abe440ece07f8deed59fb026ab020e805a;p=mmh diff --git a/sbr/dtime.c b/sbr/dtime.c index aa34621..acab877 100644 --- a/sbr/dtime.c +++ b/sbr/dtime.c @@ -12,6 +12,10 @@ #include #include +#if !defined(HAVE_STRUCT_TM_TM_GMTOFF) +extern long timezone; +#endif + /* * The number of days in the year, accounting for leap years */ @@ -99,8 +103,14 @@ dlocaltime (time_t *clock) if (tm->tm_isdst) tw.tw_flags |= TW_DST; +#ifdef HAVE_STRUCT_TM_TM_GMTOFF + tw.tw_zone = tm->tm_gmtoff / 60; + if (tm->tm_isdst) /* if DST is in effect */ + tw.tw_zone -= 60; /* reset to normal offset */ +#else tzset(); tw.tw_zone = -(timezone / 60); +#endif tw.tw_flags &= ~TW_SDAY; tw.tw_flags |= TW_SEXP; @@ -270,7 +280,10 @@ dasctime (struct tws *tw, int flags) /* - * Get the timezone for given offset + * Get the timezone for given offset. + * This used to return a three-letter abbreviation for some offset + * values. But not many. Until there's a good way to do that, + * return the string representation of the numeric offset. */ char * @@ -287,11 +300,6 @@ dtimezone (int offset, int flags) hours = offset / 60; } - if (!(flags & TW_ZONE) && mins == 0) { - tzset(); - return ((flags & TW_DST) ? tzname[1] : tzname[0]); - } - #ifdef ADJUST_NUMERIC_ONLY_TZ_OFFSETS_WRT_DST if (flags & TW_DST) hours += 1; @@ -394,20 +402,6 @@ void twscopy (struct tws *tb, struct tws *tw) { *tb = *tw; /* struct copy */ - -#if 0 - tb->tw_sec = tw->tw_sec; - tb->tw_min = tw->tw_min; - tb->tw_hour = tw->tw_hour; - tb->tw_mday = tw->tw_mday; - tb->tw_mon = tw->tw_mon; - tb->tw_year = tw->tw_year; - tb->tw_wday = tw->tw_wday; - tb->tw_yday = tw->tw_yday; - tb->tw_zone = tw->tw_zone; - tb->tw_clock = tw->tw_clock; - tb->tw_flags = tw->tw_flags; -#endif }