mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* time.c (rb_gmtime, rb_localtime): gmtime and localtime return
NULL on error. [ruby-core:23551] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23569 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
5ac1389aea
commit
762fec4946
3 changed files with 24 additions and 3 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
Tue May 26 03:41:29 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* time.c (rb_gmtime, rb_localtime): gmtime and localtime return
|
||||||
|
NULL on error. [ruby-core:23551]
|
||||||
|
|
||||||
Tue May 26 03:38:37 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Tue May 26 03:38:37 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* string.c (rb_str_each_char, rb_str_each_codepoint): string
|
* string.c (rb_str_each_char, rb_str_each_codepoint): string
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
require 'time'
|
require 'time'
|
||||||
require 'test/unit'
|
require 'test/unit'
|
||||||
|
|
||||||
class TestTimeExtention < Test::Unit::TestCase # :nodoc:
|
class TestTimeExtension < Test::Unit::TestCase # :nodoc:
|
||||||
def test_rfc822
|
def test_rfc822
|
||||||
assert_equal(Time.utc(1976, 8, 26, 14, 30) + 4 * 3600,
|
assert_equal(Time.utc(1976, 8, 26, 14, 30) + 4 * 3600,
|
||||||
Time.rfc2822("26 Aug 76 14:30 EDT"))
|
Time.rfc2822("26 Aug 76 14:30 EDT"))
|
||||||
|
|
20
time.c
20
time.c
|
@ -79,8 +79,24 @@ static int leap_year_p(long y);
|
||||||
#else
|
#else
|
||||||
#define IF_HAVE_GMTIME_R(x) /* nothing */
|
#define IF_HAVE_GMTIME_R(x) /* nothing */
|
||||||
#define ASCTIME(tm, buf) asctime(tm)
|
#define ASCTIME(tm, buf) asctime(tm)
|
||||||
#define GMTIME(tm, result) (result = *gmtime(tm), &result)
|
#define GMTIME(tm, result) rb_gmtime((tm), &(result))
|
||||||
#define LOCALTIME(tm, result) (result = *localtime(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
|
#endif
|
||||||
|
|
||||||
static ID id_divmod, id_mul, id_submicro, id_subnano;
|
static ID id_divmod, id_mul, id_submicro, id_subnano;
|
||||||
|
|
Loading…
Add table
Reference in a new issue