summaryrefslogtreecommitdiffhomepage
path: root/mrbgems/mruby-time
AgeCommit message (Collapse)Author
2020-06-20Add `mrb_get_arg1()` that retrieves single (and only) argument.Yukihiro "Matz" Matsumoto
`mrb_get_arg1()` raises `ArgumentError` if the method does not receive one argument. And replaces all `mrb_get_args(mrb, "o", &arg)` by the new function.
2020-06-03Merge pull request #4800 from ↵Yukihiro "Matz" Matsumoto
shuujii/set-MRB_STR_ASCII-flag-to-some-stringize-methods Set `MRB_STR_ASCII` flag to some stringize methods
2020-03-08Remove unnecessary 'stdio.h'; ref #4947dearblue
'stdio.h' is included in 'mruby.h' ('mrbconf.h'). However, keep 'stdio.h' used by mruby-test.
2020-02-12Fix integer boundary check before `float` to `time_t` casting.Yukihiro "Matz" Matsumoto
2019-12-31Silence GCC warning in `time.c` on Travis CIKOBAYASHI Shuji
Silence the following warnings: ``` /mruby/mrbgems/mruby-time/src/time.c:260:55: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] if ((MRB_INT_MAX > MRB_TIME_MAX && i > 0 && i > MRB_TIME_MAX) || ^ ```
2019-12-05Auto detect `MRB_TIME_T_UINT`KOBAYASHI Shuji
2019-12-03Silence Clang warning with `MRB_INT64` and `MRB_32BIT` in `time.c`KOBAYASHI Shuji
Silence the following warnings: ``` /mruby/mrbgems/mruby-time/src/time.c:871:15: warning: result of comparison of constant 9223372036854775807 with expression of type 'time_t' (aka 'long') is always false [-Wtautological-constant-out-of-range-compare] if (tm->sec > MRB_INT_MAX || tm->sec < MRB_INT_MIN) { ~~~~~~~ ^ ~~~~~~~~~~~ /mruby/mrbgems/mruby-time/src/time.c:871:40: warning: result of comparison of constant -9223372036854775808 with expression of type 'time_t' (aka 'long') is always false [-Wtautological-constant-out-of-range-compare] if (tm->sec > MRB_INT_MAX || tm->sec < MRB_INT_MIN) { ~~~~~~~ ^ ~~~~~~~~~~~ /mruby/mrbgems/mruby-time/src/time.c:887:16: warning: result of comparison of constant 9223372036854775807 with expression of type 'time_t' (aka 'long') is always false [-Wtautological-constant-out-of-range-compare] if (tm->usec > MRB_INT_MAX || tm->usec < MRB_INT_MIN) { ~~~~~~~~ ^ ~~~~~~~~~~~ /mruby/mrbgems/mruby-time/src/time.c:887:42: warning: result of comparison of constant -9223372036854775808 with expression of type 'time_t' (aka 'long') is always false [-Wtautological-constant-out-of-range-compare] if (tm->usec > MRB_INT_MAX || tm->usec < MRB_INT_MIN) { ~~~~~~~~ ^ ~~~~~~~~~~~ ```
2019-12-02Silence Clang warning with `MRB_INT32` and `MRB_64BIT` in `time.c`KOBAYASHI Shuji
Silence the following warning: ``` /mruby/mrbgems/mruby-time/src/time.c:258:60: warning: result of comparison of constant -9223372036854775808 with expression of type 'mrb_int' (aka 'int') is always false [-Wtautological-constant-out-of-range-compare] if ((mrb_time_int)i > MRB_TIME_MAX || MRB_TIME_MIN > i) { ~~~~~~~~~~~~ ^ ~ ```
2019-10-31Set `MRB_STR_ASCII` flag to some stringize methodsKOBAYASHI Shuji
- `Fixnum#to_s`, `Fixnum#inspect` - `Float#to_s`, `Float#inspect` - `NilClass#to_s`, `NilClass#inspect` - `FalseClass#to_s`, `FalseClass#inspect` - `TrueClass#to_s`, `TrueClass#inspect` - `Time#to_s`, `Time#inspect`
2019-10-10Fixed a bug in `mruby-time` with `NO_GETTIMEOFDAT`.Yukihiro "Matz" Matsumoto
2019-09-25Fix `MRB_WITHOUT_FLOAT` reversal; fix #4598dearblue
2019-08-05Use new specifiers/modifiers of `mrb_vfromat()`KOBAYASHI Shuji
The binary sizes (gems are only `mruby-bin-mruby`) are reduced slightly in my environment than before the introduction of new specifiers/modifiers (5116789a) with this change. ------------+-------------------+-------------------+-------- BINARY | BEFORE (5116789a) | AFTER (This PR) | RATIO ------------+-------------------+-------------------+-------- mruby | 593416 bytes | 593208 bytes | -0.04% libmruby.a | 769048 bytes | 767264 bytes | -0.23% ------------+-------------------+-------------------+-------- BTW, I accidentally changed `tasks/toolchains/visualcpp.rake` at #4613, so I put it back.
2019-08-03Suppress compiler warnings for mruby-time; fix #4600dearblue
Warnings: - If `MRB_TIME_T_UINT` is defined, the compiler issues a warning with an integer comparison of different signs. - It is mentioned that the `usec` variable passed to the `mrb_to_time_t()` function may not be initialized
2019-07-31Fix UTC offset representation in `Time#to_s` on some environments; ref #4604KOBAYASHI Shuji
Use own implementation to calculate UTC offset on Visual Studio 2015 or earlier or MinGW because `strftime("%z")` on these environments does not conform C99.
2019-07-29Fix Time#to_s encoding on WindowsSutou Kouhei
strftime() on Windows returns locale encoding time zone for "%z" even if MSDN says "%z" is "The offset from UTC in ISO 8601 format; no characters if time zone is unknown" in MSDN: https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/strftime-wcsftime-strftime-l-wcsftime-l?view=vs-2019 So we need to convert encoding of string from strftime().
2019-07-27Fix the lack of precision for `Time`; ref d74355061dearblue
- `Time.local` and `Time.utc` are able to use with `MRB_INT16 + MRB_WITHOUT_FLOAT`. - `time_t` is converted directly from the Ruby object. - `time + sec` and` time - sec` are not affected by the precision of `mrb_float`. Similarly, calculations are possible with `MRB_INT16 + MRB_WITHOUT_FLOAT`.
2019-07-27Fix mruby-time with `MRB_WITHOUT_FLOAT`; ref d74355061dearblue
2019-07-22Fix `mruby-time` to work with `MRB_WITHOUT_FLOAT`; ref #4576Yukihiro "Matz" Matsumoto
As a side effect, `mrb_time_at()` now takes `mrb_int` instead of `double` as time arguments.
2019-07-22Improve conflict error message of `Time` and `Math`; ref #4576Yukihiro "Matz" Matsumoto
2019-07-14Error needed/conflicts configurationdearblue
The purpose is to clarify the error if there is a needed/conflicts configuration at compile time.
2019-05-24Fix the order of "expected" and "actual" in `mruby-time` testKOBAYASHI Shuji
2019-05-16Refactor `time.c` regarding memory allocation.Yukihiro "Matz" Matsumoto
2019-05-14Refine `Time#(to_s|inspect)`KOBAYASHI Shuji
For the following reasons: - Ruby compatibility. - Add UTC offset (time zone informations was not included by #4433). - More readable. Example: Before this patch: p Time.gm(2003,4,5,6,7,8,9) #=> Sat Apr 5 06:07:08 2003 p Time.local(2013,10,28,16,27,48) #=> Mon Oct 28 16:27:48 2013 After this patch: p Time.gm(2003,4,5,6,7,8,9) #=> 2003-04-05 06:07:08 UTC p Time.local(2013,10,28,16,27,48) #=> 2013-10-28 16:27:48 +0900 Implementation: I use `strftime(3)` because UTC offset can be added and program size become smaller than the other implementations (using `sprintf(3)`, self conversion etc) in my environment.
2019-05-13Fix `Time#(asctime|ctime)` according to ISO RubyKOBAYASHI Shuji
- A leading charactor for day is space. - Time zone does not included. Before this patch: Time.gm(1982,3,4,5,6,7).asctime #=> "Thu Mar 04 05:06:07 UTC 1982" After this patch: Time.gm(1982,3,4,5,6,7).asctime #=> "Thu Mar 4 05:06:07 1982"
2019-05-12Fix missing assertions in `mruby-time` testKOBAYASHI Shuji
2019-03-02Free `struct mrb_time` before error; fix #4308Yukihiro "Matz" Matsumoto
To avoid memory leak from `time_update_datetime`.
2019-01-26fix Time about carry-up and carry-downtakkaw
2019-01-08Export Time creation APItake-cheeze
2018-12-23Suppress _MSC_VER warns for mingw32dearblue
2018-12-19Added Android Hack to `time.c`.Yukihiro "Matz" Matsumoto
Android bionic defines `TIME_UTC` but does not provide `timespec_get`.
2018-01-30Merge pull request #3936 from ken-mu/uintYukihiro "Matz" Matsumoto
mruby-time: support time_t is uint
2018-01-29mruby-time: remove ifdef for mktime error handlingken-mu
2018-01-28mruby-time: support time_t is uintken-mu
2018-01-24`Time.new(1969,12,31,23,59,59)` may or may not faile; ref #3932Yukihiro "Matz" Matsumoto
On some platform and timezone it is a valid time spec.
2018-01-21mruby-time: remove test case less than Dec 31 23:59:58 1969ken-mu
2018-01-20mruby-time: Fix mruby specific timegm() cannot return minusken-mu
2017-09-27fix: mrbgems\mruby-time\src\time.c(641): warning C4244: '=': conversion from ↵Tomasz Dąbrowski
'mrb_int' to 'int', possible loss of data
2017-09-27fix: mrbgems\mruby-time\src\time.c(372): warning C4244: 'function': ↵Tomasz Dąbrowski
conversion from 'mrb_int' to 'double', possible loss of data
2017-09-25change DISABLE_STDIO to MRB_DISABLE_STDIO in mruby-time/time.cTomasz Dabrowski
2017-07-13Use `floor()` to implement `round()` on WIN32 platform.Yukihiro "Matz" Matsumoto
This change was suggested by Akira Kakuto.
2017-07-13Define `round()` only on WIN32 platform; fix #3741Yukihiro "Matz" Matsumoto
2017-04-25Add explicit cast from double to long.Yukihiro "Matz" Matsumoto
2017-04-25Avoid use of `snprintf()` when DISABLE_STDIO is set; fix #3632Yukihiro "Matz" Matsumoto
ref #3492 #3515 #3517
2017-04-03Correctly handle large negative usec value.Clayton Smith
2017-04-03Unify `else` clause styleYukihiro "Matz" Matsumoto
2017-04-01Improve Time.new() performance using division; fix #3561Yukihiro "Matz" Matsumoto
2017-03-29Should raise FloatDomainErrorksss
2017-03-28Fix infinity loopksss
And some cases should raise FloatDomainError
2017-01-09Validate tm values before timegm(); close #3368Yukihiro "Matz" Matsumoto
This issue was reported by https://hackerone.com/volc
2017-01-02add explicit castsYukihiro "Matz" Matsumoto