summaryrefslogtreecommitdiffhomepage
path: root/mrbgems/mruby-time/src/time.c
AgeCommit message (Collapse)Author
2021-08-21Organize the include of header filesdearblue
- `#include <math.h>` is done in `mruby.h`. Eliminate the need to worry about the `MRB_NO_FLOAT` macro. - Include mruby header files before standard header files. If the standard header file is already placed before `mruby.h`, the standard header file added in the future tends to be placed before `mruby.h`. This change should some reduce the chances of macros that must be defined becoming undefined in C++ or including problematic header files in a particular mruby build configuration.
2021-07-25time.c: fixed a potential buffer overflow in `time_zonename`.Yukihiro "Matz" Matsumoto
2021-07-25time.c: fixed `time_zonename` buffer size bug.Yukihiro "Matz" Matsumoto
2021-07-25time.c: stop returning `LOCAL` for the zone name from `Time.zone`.Yukihiro "Matz" Matsumoto
2021-07-25time.c: update the document for `Time#usec`; close #5515Yukihiro "Matz" Matsumoto
2021-07-25Remove redundant include headers.Yukihiro "Matz" Matsumoto
- stdlib.h - stddef.h - stdint.h - stdarg.h - limits.h - float.h
2021-05-08time.c: Windows API provides `clock_gettime`.Yukihiro "Matz" Matsumoto
`gettimeofday` emulation needed no longer.
2021-04-24time.c: `fixable_time_t_p` is not used with `MRB_NO_FLOAT`; #5421Yukihiro "Matz" Matsumoto
2021-04-23time.c: `time_t` may be unsigned on some platforms.Yukihiro "Matz" Matsumoto
2021-04-19time.c: add integer boundary check for year.Yukihiro "Matz" Matsumoto
On configurations where `sizeof(mrb_int) > sizeof(int)`.
2021-03-14time.c: calendar clock should use `CLOCK_REALTIME`; 5e95f11Yukihiro "Matz" Matsumoto
The issue was reported by @shuujii
2021-03-08time.c: fix errors on Windows and macOS; ref #5354Yukihiro "Matz" Matsumoto
`gmtime_r` detection logic was too strict.
2021-03-08ISO C99 doesn't support unnamed unions; fix #5354Yukihiro "Matz" Matsumoto
2021-03-03time.c: `timespec_get()` never fails.Yukihiro "Matz" Matsumoto
2021-03-03time.c: fixed wrong condition to include `unistd.h`.Yukihiro "Matz" Matsumoto
2021-03-03time.c: Windows does not have `unistd.h`.Yukihiro "Matz" Matsumoto
2021-03-03time.c: use `clock_gettime()` if possible.Yukihiro "Matz" Matsumoto
2021-03-03time.c: adjust buffer size in `mrb_time_asctime()`.Yukihiro "Matz" Matsumoto
2021-03-03time.c: fix compile errors in `mrb_time_asctime()`.Yukihiro "Matz" Matsumoto
2021-03-01time.c: fixed a bug on no builtin overflow (e.g. VC).Yukihiro "Matz" Matsumoto
2021-03-01time.c: avoid using `mrb_int_{add,sub}_overflow()`.Yukihiro "Matz" Matsumoto
The size and signedness of `mrb_int` and `time_t` may differ.
2021-02-28time.c: check overflow in addition and subtraction of `Time`.Yukihiro "Matz" Matsumoto
2021-02-28Remove periods from error messages according to the convention.Yukihiro "Matz" Matsumoto
2021-02-28time.c: change `RuntimeError` to `ArgumentError`.Yukihiro "Matz" Matsumoto
2021-01-26Revert "Minimize the changes in #5277"Yukihiro "Matz" Matsumoto
This reverts commit dc51d89ac22acc60b9bfeed87115863565b74085.
2021-01-22Minimize the changes in #5277Yukihiro "Matz" Matsumoto
Instead of including `mruby/presym.h` everywhere, we provided the fallback `mruby/presym.inc` under `include/mruby` directory, and specify `-I<build-dir>/include` before `-I<top-dir>/include` in `presym.rake`. So even when someone drops `-I<build-dir>/include` in compiler options, it just compiles without failure.
2021-01-11Avoid including `presym.inc` in existing header filesKOBAYASHI Shuji
Addressed an issue where existing programs linking `libmruby.a` could only be built by adding `<build-dir>/include` to compiler's include path.
2020-11-21Rename `MRB_{ENABLE,DISABLE}_` to `MRB_{USE,NO}_`; close #5163KOBAYASHI Shuji
| Previous Name | New Name | |------------------------------|-------------------------| | MRB_ENABLE_ALL_SYMBOLS | MRB_USE_ALL_SYMBOLS | | MRB_ENABLE_SYMBOLL_ALL | MRB_USE_ALL_SYMBOLS | | MRB_ENABLE_CXX_ABI | MRB_USE_CXX_ABI | | MRB_ENABLE_CXX_EXCEPTION | MRB_USE_CXX_EXCEPTION | | MRB_ENABLE_DEBUG_HOOK | MRB_USE_DEBUG_HOOK | | MRB_DISABLE_DIRECT_THREADING | MRB_NO_DIRECT_THREADING | | MRB_DISABLE_STDIO | MRB_NO_STDIO | | ENABLE_LINENOISE | MRB_USE_LINENOISE | | ENABLE_READLINE | MRB_USE_READLINE | | DISABLE_MIRB_UNDERSCORE | MRB_NO_MIRB_UNDERSCORE | | DISABLE_GEMS | MRB_NO_GEMS | * `MRB_ENABLE_SYMBOLL_ALL` seems to be a typo, so it is fixed. * `MRB_` prefix is added to those without. * The previous names can also be used for compatibility.
2020-10-12Use `mrb_integer()` instead of `mrb_int()`.Yukihiro "Matz" Matsumoto
`mrb_int()` includes implicit integer conversion, where `mrb_integer()` does not. In this case, we know `obj` is an integer before hand.
2020-10-12Use `mrb_int_value()` instead of `mrb_fixnum_value()`.Yukihiro "Matz" Matsumoto
Where fixnum overflow can happen.
2020-10-12Reorganize `Integer` system.Yukihiro "Matz" Matsumoto
- Integrate `Fixnum` and `Integer` - Remove `Integral` - `int / int -> int` - Replace `mrb_fixnum()` to `mrb_int()` - Replace `mrb_fixnum_value()` to `mrb_int_value()`. - Use `mrb_integer_p()` instead of `mrb_fixnum_p()`
2020-10-12Rename `MRB_TT_FIXNUM` to `MRB_TT_INTEGER`.Yukihiro "Matz" Matsumoto
We still have `#define MRB_TT_FIXNUM MRB_TT_INTEGER` for compatibility.
2020-10-12Rename float configuration option names.Yukihiro "Matz" Matsumoto
- `MRB_WITHOUT_FLOAT` => `MRB_NO_FLOAT` - `MRB_USE_FLOAT` => `MRB_USE_FLOAT32` The former is to use `USE_XXX` naming convention. The latter is to make sure `float` is 32bit float and not floating point number in general.
2020-10-12Change out-of-range condition of `time_t` conversion.Yukihiro "Matz" Matsumoto
2020-10-12Avoid out-of-range error for negative time on `MRB_TIME_T_UINT`.Yukihiro "Matz" Matsumoto
On platforms where `time_t` is unsigned, negative time can be a result of integer casting. Out-of-range error is too strict for those cases. This fix does not address wrong time value in `MRB_WORD_BOXING`. It will be addressed later (by introducing "big" integers).
2020-10-12Use functions that take symbols to reduce string litrals in C.Yukihiro "Matz" Matsumoto
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.