From 79a5d02e194a5eee47ce2456019cfe2d31565969 Mon Sep 17 00:00:00 2001 From: matz Date: Tue, 20 Jun 2000 06:08:52 +0000 Subject: 2000-06-20 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_4@770 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- time.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'time.c') diff --git a/time.c b/time.c index 41f08842eb..e734155fc6 100644 --- a/time.c +++ b/time.c @@ -292,19 +292,16 @@ make_time_t(tptr, utc_or_local) if (!tm) goto error; if (tptr->tm_year != tm->tm_year) goto out_of_range; } - guess += (tptr->tm_mday - tm->tm_mday) * 3600 * 24; + guess += (tptr->tm_mday - tm->tm_mday) * 24 * 3600; guess += (tptr->tm_hour - tm->tm_hour) * 3600; guess += (tptr->tm_min - tm->tm_min) * 60; guess += (tptr->tm_sec - tm->tm_sec); if (guess < 0) goto out_of_range; if (!utc_or_local) { /* localtime zone adjust */ -#if defined(HAVE_DAYLIGHT) - extern int daylight; - extern long timezone; - - localtime(&guess); - guess += timezone + daylight; +#if defined(HAVE_TM_ZONE) + tm = localtime(&guess); + guess -= tm->tm_gmtoff; #else struct tm gt, lt; long tzsec; @@ -799,8 +796,14 @@ time_zone(time) time_get_tm(time, tobj->gmt); } +#if defined(HAVE_TM_ZONE) + return rb_str_new2(tobj->tm.tm_zone); +#elif defined(HAVE_TZNAME) && defined(HAVE_DAYLIGHT) + return rb_str_new2(tzname[daylight && tobj->tm.tm_isdst]); +#else len = strftime(buf, 64, "%Z", &tobj->tm); return rb_str_new(buf, len); +#endif } static VALUE -- cgit v1.2.3