87 Commits

Author SHA1 Message Date
Yukihiro "Matz" Matsumoto 3498a787ba Merge pull request #3936 from ken-mu/uint
mruby-time: support time_t is uint
2018-01-30 12:42:49 +09:00
ken-mu a1b71b64b3 mruby-time: remove ifdef for mktime error handling 2018-01-29 09:43:43 +00:00
ken-mu 6a2c0c6e2a mruby-time: support time_t is uint 2018-01-28 03:03:20 +00:00
Yukihiro "Matz" Matsumoto 3ff56a8e55 Time.new(1969,12,31,23,59,59) may or may not faile; ref #3932
On some platform and timezone it is a valid time spec.
2018-01-24 21:42:25 +09:00
ken-mu d398cd47d7 mruby-time: remove test case less than Dec 31 23:59:58 1969 2018-01-21 02:47:17 +00:00
ken-mu a1f36316d2 mruby-time: Fix mruby specific timegm() cannot return minus 2018-01-20 13:09:58 +00:00
Tomasz Dąbrowski be81504770 fix: mrbgems\mruby-time\src\time.c(641): warning C4244: '=': conversion from 'mrb_int' to 'int', possible loss of data 2017-09-27 22:22:04 +02:00
Tomasz Dąbrowski 0848407ee5 fix: mrbgems\mruby-time\src\time.c(372): warning C4244: 'function': conversion from 'mrb_int' to 'double', possible loss of data 2017-09-27 22:22:04 +02:00
Tomasz Dabrowski e00b48be4a change DISABLE_STDIO to MRB_DISABLE_STDIO in mruby-time/time.c 2017-09-25 13:11:20 +02:00
Yukihiro "Matz" Matsumoto bad807e7f0 Use floor() to implement round() on WIN32 platform.
This change was suggested by Akira Kakuto.
2017-07-13 20:32:34 +09:00
Yukihiro "Matz" Matsumoto 70e99d6b57 Define round() only on WIN32 platform; fix #3741 2017-07-13 00:09:31 +09:00
Yukihiro "Matz" Matsumoto 92dcfbaab3 Add explicit cast from double to long. 2017-04-25 17:43:03 +09:00
Yukihiro "Matz" Matsumoto 88cd807379 Avoid use of snprintf() when DISABLE_STDIO is set; fix #3632
ref #3492 #3515 #3517
2017-04-25 10:41:50 +09:00
Clayton Smith dc4fba28c5 Correctly handle large negative usec value. 2017-04-03 14:22:26 -04:00
Yukihiro "Matz" Matsumoto 77331d127b Unify else clause style 2017-04-03 16:56:27 +09:00
Yukihiro "Matz" Matsumoto 8d9d7c929e Improve Time.new() performance using division; fix #3561 2017-04-01 13:03:34 +09:00
ksss db3573e0bf Should raise FloatDomainError 2017-03-29 11:59:19 +09:00
ksss 397f1fc946 Fix infinity loop
And some cases should raise FloatDomainError
2017-03-28 10:58:18 +09:00
Yukihiro "Matz" Matsumoto c4491e477b Validate tm values before timegm(); close #3368
This issue was reported by https://hackerone.com/volc
2017-01-09 10:42:11 +09:00
Yukihiro "Matz" Matsumoto bc1259de3b add explicit casts 2017-01-02 17:48:44 +09:00
Yukihiro "Matz" Matsumoto 07167b8f5e Initialize potentially uninitialized variable tsec. 2017-01-01 00:47:45 +09:00
Yukihiro "Matz" Matsumoto 9a962ed2c3 Raise an exception in time_update_datetime().
The function used to return NULL on error, but not checked in the
caller site.
2016-12-06 10:27:35 +09:00
Yukihiro "Matz" Matsumoto 3d9aa463f7 Add NULL checks for Time data retrieval 2016-11-27 20:47:20 +09:00
Yukihiro "Matz" Matsumoto 277e81a7c9 removed failing test for Time#initialize; ref #3295 2016-11-26 12:02:46 +09:00
Bouke van der Bijl b7f9a58757 Fix null pointer dereference in mrb_time_initialize
Reported by https://hackerone.com/raydot
2016-11-25 11:15:57 -05:00
Yukihiro "Matz" Matsumoto 23c73ff399 Time#initialize_copy: Check if source time is initialized.
To prevent crash from nasty code like:

  class Time
    def initialize
    end
  end

  a = Time.new
  b = Time.new
  a.initialize_copy b
2016-11-24 13:50:36 +09:00
Yukihiro "Matz" Matsumoto d97a37eb7b fix possible memory leak in mruby-time gem 2016-04-04 21:58:46 +09:00
Paolo Bosetti 67e3cdfa76 Implemented round(double) function within mruby-time gem, for it is missing on
VisualStudio compilers where _MSC_ver < 1800
2015-11-27 10:54:03 +01:00
Yukihiro "Matz" Matsumoto 5c405dea3d include changed from by quotes ("") to by brackets (<>); close #3032 2015-11-27 17:48:23 +09:00
Yasuhiro Matsumoto 1167fd1ae4 use round for llround. some platform (ex: mingw32) doesn't have llround. 2015-07-09 11:02:34 +09:00
Yukihiro "Matz" Matsumoto 6a796cb4cc Added a check for 64 bit time_t overflow; based on a patch from @kext; close #2836 2015-06-17 09:19:09 +09:00
Lukas Joeressen 47c61cf502 Changed llrint to llround 2015-06-16 09:24:27 +02:00
Lukas Joeressen 95fa22a65c Rounding errors could make time_alloc imprecise 2015-06-15 15:03:44 +02:00
cremno c47cc0c3bb call C11's timespec_get()
gettimeofday() is an obsolescent POSIX function which may be removed in
a future version. POSIX recommends using clock_gettime() (also POSIX)
instead, but it isn't available on OS X or Windows (at least with MSVC
and older MinGW versions).

Whereas timespec_get() is part of ISO C11 and mruby uses some small
other C11 features too. It isn't universally available yet either, but
it might be in the future. And Visual C++ 2015 implements it! Since
mruby strives for ISO C and not POSIX compatibility, I think it's a
reasonable choice.

TIME_UTC is used instead of __STDC_VERSION__, because if TIME_UTC is
defined, then most likely timespec_get() is too. This isn't true in case
of  __STDC_VERSION__ (see MSVC).
2015-03-22 22:52:12 +01:00
Yukihiro "Matz" Matsumoto b4cc962c3a add similar range check for tm->usec as well 2014-10-03 14:58:59 +09:00
Yukihiro "Matz" Matsumoto 95b3a70291 always check range before casting time_t to mrb_int 2014-10-03 14:57:22 +09:00
Yukihiro "Matz" Matsumoto 88d14e03d0 time_t may overflow mrb_int when word boxing is used 2014-10-03 11:10:09 +09:00
take_cheeze b3d0585fe5 Add API mrb_data_init to initialize MRB_TT_DATA tagged instance. 2014-08-20 22:42:35 +09:00
dycoon e7249e4590 timer on windows bug fixed. 2014-08-09 21:40:52 +09:00
Yukihiro "Matz" Matsumoto 0878900fda Time#to_i and Time#usec should care about mrb_int overflow on MRB_INT16; ref #2495 2014-08-03 20:36:20 +09:00
take_cheeze 8106760077 Use MRB_ARGS_ARG(n, o) instead of MRB_ARGS_REQ(n) | MRB_ARGS_OPT(o). 2014-07-02 21:11:12 +09:00
Yukihiro "Matz" Matsumoto e749267909 time overflow check; ref #2337 2014-07-02 10:28:10 +09:00
take_cheeze 77047b5ed4 Test all ISO defined classes direct superclass except Object class.
Move mrbgems ISO direct superclass test to `superclass.rb`.
Skips test if class isn't defined.
Close #2332.
2014-06-15 17:07:01 +09:00
take_cheeze d386b35337 Fix Time.at args spec. 2014-06-09 16:34:04 +09:00
kyab 4a05dce4a3 pacify MSVC warnings for time.c 2014-05-09 23:38:05 +09:00
take_cheeze f0154d6e3a Remove Time defined check in test. 2014-05-07 21:21:18 +09:00
mattn 0b5fe0ad6f Fix build on mingw32/64: struct timeval isn't defined in default. See: 642477ef6a 2014-05-07 10:18:57 +09:00
take_cheeze 7bab3d0bb2 Implement day of week methods. 2014-05-05 22:41:16 +09:00
windwiny 642477ef6a Update time.c
miss __MINGW32__ macro check
2014-05-02 22:28:09 +08:00
cremno 06a946abb2 mruby-time: fix check of mktime's return value
>If the calendar time cannot be represented, the function returns the
value (time_t)(-1).
http://www.iso-9899.info/n1256.html#7.23.2.3p3
2014-04-13 16:43:13 +02:00