summaryrefslogtreecommitdiff
path: root/time.c
diff options
context:
space:
mode:
author(no author) <(no author)@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2001-06-04 09:02:30 +0000
committer(no author) <(no author)@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2001-06-04 09:02:30 +0000
commit469c1f3f40f279906aceceb7cd4aef80eeffd642 (patch)
tree37d0caae0cb84f774c364bfa2077423a31144e5f /time.c
parent99020d6e50702eb371111d73280eb80b4b29ba5b (diff)
This commit was manufactured by cvs2svn to create tag 'v1_6_4'.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/tags/v1_6_4@1498 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'time.c')
-rw-r--r--time.c25
1 files changed, 16 insertions, 9 deletions
diff --git a/time.c b/time.c
index e45e2e854a..b9008c974d 100644
--- a/time.c
+++ b/time.c
@@ -324,11 +324,6 @@ make_time_t(tptr, utc_or_local)
if (guess < 0) goto out_of_range;
if (!utc_or_local) { /* localtime zone adjust */
-#if defined(HAVE_TM_ZONE)
- tm = localtime(&guess);
- if (!tm) goto error;
- guess -= tm->tm_gmtoff;
-#else
struct tm gt, lt;
long tzsec;
@@ -357,10 +352,22 @@ make_time_t(tptr, utc_or_local)
}
tm = localtime(&guess);
if (!tm) goto error;
- if (lt.tm_isdst != tm->tm_isdst) {
- guess -= 3600;
+ if (lt.tm_isdst != tm->tm_isdst || tptr->tm_hour != tm->tm_hour) {
+ time_t tmp = guess - 3600;
+ tm = localtime(&tmp);
+ if (!tm) goto error;
+ if (tptr->tm_hour == tm->tm_hour) {
+ guess = tmp;
+ }
+ else if (lt.tm_isdst == tm->tm_isdst) {
+ tmp = guess + 3600;
+ tm = localtime(&tmp);
+ if (!tm) goto error;
+ if (tptr->tm_hour == tm->tm_hour) {
+ guess = tmp;
+ }
+ }
}
-#endif
if (guess < 0) {
goto out_of_range;
}
@@ -891,7 +898,7 @@ rb_strftime(buf, format, time)
return 0;
}
len = strftime(*buf, SMALLBUF, format, time);
- if (len != 0) return len;
+ if (len != 0 || **buf == '\0') return len;
for (size=1024; ; size*=2) {
*buf = xmalloc(size);
(*buf)[0] = '\0';