diff options
| author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-05-25 18:41:32 +0000 |
|---|---|---|
| committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-05-25 18:41:32 +0000 |
| commit | f17f98370e292c10925f27476e2de5671cea8bdd (patch) | |
| tree | 5e1ca375eafa632cf137335ec096ce89ed688137 /time.c | |
| parent | d62dabb4c36514591417a80eac50e79257e96613 (diff) | |
| download | ruby-f17f98370e292c10925f27476e2de5671cea8bdd.tar.gz ruby-f17f98370e292c10925f27476e2de5671cea8bdd.tar.xz ruby-f17f98370e292c10925f27476e2de5671cea8bdd.zip | |
* time.c (rb_gmtime, rb_localtime): gmtime and localtime return
NULL on error. [ruby-core:23551]
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@23569 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'time.c')
| -rw-r--r-- | time.c | 20 |
1 files changed, 18 insertions, 2 deletions
@@ -79,8 +79,24 @@ static int leap_year_p(long y); #else #define IF_HAVE_GMTIME_R(x) /* nothing */ #define ASCTIME(tm, buf) asctime(tm) -#define GMTIME(tm, result) (result = *gmtime(tm), &result) -#define LOCALTIME(tm, result) (result = *localtime(tm), &result) +#define GMTIME(tm, result) rb_gmtime((tm), &(result)) +#define LOCALTIME(tm, result) rb_localtime((tm), &(result)) + +static inline struct tm * +rb_gmtime(const time_t *tm, struct tm *result) +{ + struct tm *t = gmtime(tm); + if (t) *result = *t; + return t; +} + +static inline struct tm * +rb_localtime(const time_t *tm, struct tm *result) +{ + struct tm *t = localtime(tm); + if (t) *result = *t; + return t; +} #endif static ID id_divmod, id_mul, id_submicro, id_subnano; |
