From 99155ccbf20efb98ce97145b9aee95fb487262cc Mon Sep 17 00:00:00 2001 From: shugo Date: Wed, 20 Aug 2008 16:04:11 +0000 Subject: * configure.in: removed strftime from AC_REPLACE_FUNCS(). * include/ruby/missing.h: removed prototype for strftime(). * missing/strftime.c: removed. * time.c (time_to_s): use rb_strftime() instead of strftime(3). (time_zone): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18734 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- time.c | 31 ++++++++++--------------------- 1 file changed, 10 insertions(+), 21 deletions(-) (limited to 'time.c') diff --git a/time.c b/time.c index 194296729f..3556870ada 100644 --- a/time.c +++ b/time.c @@ -1353,6 +1353,10 @@ time_asctime(VALUE time) return rb_str_new2(s); } +size_t +rb_strftime(char *s, size_t maxsize, const char *format, + const struct tm *timeptr, const struct timespec *ts, int gmt); + /* * call-seq: * time.inspect => string @@ -1381,24 +1385,12 @@ time_to_s(VALUE time) time_get_tm(time, tobj->gmt); } if (tobj->gmt == 1) { - len = strftime(buf, 128, "%Y-%m-%d %H:%M:%S UTC", &tobj->tm); + len = rb_strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S UTC", + &tobj->tm, &tobj->ts, tobj->gmt); } else { - long off; - char sign = '+'; -#if defined(HAVE_STRUCT_TM_TM_GMTOFF) - off = tobj->tm.tm_gmtoff; -#else - VALUE tmp = time_utc_offset(time); - off = NUM2INT(tmp); -#endif - if (off < 0) { - sign = '-'; - off = -off; - } - len = strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S ", &tobj->tm); - len += snprintf(buf+len, sizeof(buf)-len, "%c%02d%02d", sign, - (int)(off/3600), (int)(off%3600/60)); + len = rb_strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S %z", + &tobj->tm, &tobj->ts, tobj->gmt); } return rb_str_new(buf, len); } @@ -1918,7 +1910,8 @@ time_zone(VALUE time) #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); + len = rb_strftime(buf, sizeof(buf), "%Z", + &tobj->tm, &tobj->ts, tobj->gmt); return rb_str_new(buf, len); #endif } @@ -2016,10 +2009,6 @@ time_to_a(VALUE time) time_zone(time)); } -size_t -rb_strftime(char *s, size_t maxsize, const char *format, - const struct tm *timeptr, const struct timespec *ts, int gmt); - #define SMALLBUF 100 static int rb_strftime_alloc(char **buf, const char *format, -- cgit v1.2.3