summaryrefslogtreecommitdiff
path: root/time.c
AgeCommit message (Collapse)Author
2025-04-09merge revision(s) 06919949a60b42a8f30e8bd0cb075e17b05eebcd, ↵nagachika
51bc992822f9108ad64de32d300e1cefd0e2da59, 42daa6c2a2b49b4e45f40736e25c7d182860f24a: [Backport #21141] [Bug #21141] [DOC] Clarify what time is in UTC [Bug #21141] [DOC] Refine description of `Time#utc?` [Bug #21141] [DOC] Fix indentation
2025-03-16merge revision(s) 3f07bc76ff6a11232d9f18e5eaa31835c195e8f0, ↵nagachika
34098b669c0cbc024cd08e686891f1dfe0a10aaf: [Backport #21144] [Bug #21144] Win32: Use Windows time zone ID if TZ is not set If the TZ environment variable is not set, the time zone names retrieved from the system are localized for UI display and may vary across editions and language packs for the same time zone. Use the time zone IDs that are invariant across environments instead. [Bug #21144] Win32: Convert the time zone name to the current locale The Windows time zone IDs provided by Microsoft as of 24H1 are ASCII only all, but the API itself is not impossible to set non-ASCII key name. Prefer the current locale encoding for now until we move to UTF-8 including environment variables and command line arguments.
2024-05-30merge revision(s) ↵Takashi Kokubun
055613fd868a8c94e43893f8c58a00cdd2a81f6d,127d7a35df10ee2bc99f44b888972b2c5361d84f,e2a9b87126d59e4766479a7aa12cf7a648f46506: [Backport #20447] Fix pointer incompatiblity Since the subsecond part is discarded, WIDEVAL to VALUE conversion is needed. Some functions are not used when `THREAD_MODEL=none` `rb_thread_sched_destroy` is not used now at all
2024-03-21merge revision(s) d3279a0c11ca45ca85027e7eb74dc4aac52c478b: [Backport ↵NARUSE, Yui
#20327] (#10313) [Bug #20327] Do not count subsecond to calculate UTC offset Assume that there will never be any time zones with UTC offsets that are subseconds. Historically, UTC offset has only been used down to the second.
2023-12-02[DOC] Markup class name `Time` as codeNobuyoshi Nakada
2023-12-02[DOC] Include timezones document in timev.rbNobuyoshi Nakada
So that it can be referred as a part of the document of `Time`.
2023-11-21Get rid of useless dsize functionsJean Boussier
If we always return 0, we might as well not define the function at all.
2023-11-07Use embedded TypedData for Time objectsPeter Zhu
This drops the total size of a Time object from 86 bytes to 80 bytes. Running the benchmark benchmark/time_now.yml, this commit improves performance of Time.now by about 30%: ``` Time.now Branch: 13159405.4 i/s Master: 10036908.7 i/s - 1.31x slower Time.now(in: "+09:00") Branch: 2712172.6 i/s Master: 2138637.9 i/s - 1.27x slower ``` It also decreases memory usage by about 20%: ``` ary = 10_000_000.times.map { Time.now } puts `ps -o rss= -p #{$$}` ``` Branch: 961792 Master: 1196544 Co-Authored-By: Jean Boussier <byroot@ruby-lang.org>
2023-08-16[DOC] Specify the unit of return value for `Time#-`haseponpon
Notes: Merged: https://github.com/ruby/ruby/pull/8217 Merged-By: nobu <nobu@ruby-lang.org>
2023-08-15[DOC] Improve doc guide compliance (#8221)Burdette Lamar
2023-07-13Tighten Time.new(string) parsingJeremy Evans
Disallow: * Only year-month * Only year-month-day * Preceding whitespace * Trailing whitespace Fixes [Bug #19293] Notes: Merged: https://github.com/ruby/ruby/pull/7974
2023-06-23Prefer `0` over `NULL` as function pointersNobuyoshi Nakada
SunC warns use of `NULL`, pointer to data as function pointers. Notes: Merged: https://github.com/ruby/ruby/pull/7972 Merged-By: nobu <nobu@ruby-lang.org>
2023-04-04Fix crash in Time on 32-bit systemsPeter Zhu
[Bug #19575] struct vtm is packed causing it to have a size that is not aligned on 32-bit systems. When allocating it on the stack, it will have unaligned addresses which means that the fields won't be marked by the GC when scanning the stack (since the GC only marks aligned addresses). This can cause crashes when the fields are heap allocated objects like Bignums. This commit moves the flags in struct time_object into struct vtm for space efficiency and removes the need for packing. This is an example of a crash: ruby(rb_print_backtrace+0xd) [0x56848945] ../src/vm_dump.c:785 ruby(rb_vm_bugreport) ../src/vm_dump.c:1101 ruby(rb_assert_failure+0x7a) [0x56671857] ../src/error.c:878 ruby(vm_search_cc+0x0) [0x56666e47] ../src/vm_method.c:1366 ruby(rb_vm_search_method_slowpath) ../src/vm_insnhelper.c:2090 ruby(callable_method_entry+0x5) [0x568232d3] ../src/vm_method.c:1406 ruby(rb_callable_method_entry) ../src/vm_method.c:1413 ruby(gccct_method_search_slowpath) ../src/vm_eval.c:427 ruby(gccct_method_search+0x20f) [0x568237ef] ../src/vm_eval.c:476 ruby(opt_equality_by_mid_slowpath+0x2c) [0x5682388c] ../src/vm_insnhelper.c:2338 ruby(rb_equal+0x37) [0x566fe577] ../src/object.c:133 ruby(rb_big_eq+0x34) [0x56876ee4] ../src/bignum.c:5554 ruby(rb_int_equal+0x14) [0x566f3ed4] ../src/numeric.c:4640 ruby(rb_int_equal) ../src/numeric.c:4634 ruby(vm_call0_cfunc_with_frame+0x6d) [0x568303c2] ../src/vm_eval.c:148 ruby(vm_call0_cfunc) ../src/vm_eval.c:162 ruby(vm_call0_body) ../src/vm_eval.c:208 ruby(rb_funcallv_scope+0xd1) [0x56833971] ../src/vm_eval.c:85 ruby(RB_TEST+0x0) [0x567e8488] ../src/time.c:78 ruby(eq) ../src/time.c:78 ruby(small_vtm_sub) ../src/time.c:1523 ruby(timelocalw+0x23b) [0x567f3e9b] ../src/time.c:1593 ruby(time_s_alloc+0x0) [0x567f536b] ../src/time.c:3698 ruby(time_new_timew) ../src/time.c:2694 ruby(time_s_mktime) ../src/time.c:3698 Notes: Merged: https://github.com/ruby/ruby/pull/7650
2023-02-19Remove (newly unneeded) remarks about aliasesBurdetteLamar
2023-02-08Replace `PACKED_STRUCT` and `PACKED_STRUCT_UNALIGNED`Nobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/7268
2023-02-07* remove trailing spaces. [ci skip]git
2023-02-07Make Time objects WB protectedPeter Zhu
Co-Authored-By: Jean Boussier <byroot@ruby-lang.org> Notes: Merged: https://github.com/ruby/ruby/pull/7244
2023-02-07Remove unused code in time.cPeter Zhu
Co-Authored-By: Jean Boussier <byroot@ruby-lang.org> Notes: Merged: https://github.com/ruby/ruby/pull/7244
2023-01-02[Bug #19296] Precheck bits of time componentsNobuyoshi Nakada
2023-01-01[Bug #19292] Re-initialize tm when wday or yday is not setNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/7051
2022-12-22Update documentation about Time#deconstruct_keysKazuki Tsujimoto
2022-12-21[DOC] fix unintentional verbatimNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/6975
2022-12-19Fix guess_diff typeNobuyoshi Nakada
`unsigned_time_t` has the same size as `time_t`, but it doesn't mean these types are same except for signedness. For instance, while `long` and `long long` has the same size and `time_t` is defined as the latter on 64bit OpenBSD, `unsigned_time_t` has been defined as `long`.
2022-12-16[Feature #18033] Parse more strictly conformant with ISO-8601Nobuyoshi Nakada
* 4-digits or more is required as year * Minutes and seconds parts are not ommittable Notes: Merged: https://github.com/ruby/ruby/pull/4825
2022-12-16[Feature #18033] Make more conformant with C standardNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/4825
2022-12-16[Feature #18033] Add `precision:` optionNobuyoshi Nakada
Which limits the precision of subsecond. Defaulted to 9, that means nanosecond. Notes: Merged: https://github.com/ruby/ruby/pull/4825
2022-12-16[Feature #18033] More strict checksNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/4825
2022-12-16[Feature #18033] Name a magic numberNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/4825
2022-12-16[Feature #18033] Make Time.new parse time stringsNobuyoshi Nakada
`Time.new` now parses strings such as the result of `Time#inspect` and restricted ISO-8601 formats. Notes: Merged: https://github.com/ruby/ruby/pull/4825
2022-11-22Add Time#deconstruct_keyszverok
Notes: Merged: https://github.com/ruby/ruby/pull/6594
2022-11-16Using UNDEF_P macroS-H-GAMELINKS
Notes: Merged: https://github.com/ruby/ruby/pull/6721
2022-11-15Re-order checks for colons in UTC offsetNobuyoshi Nakada
2022-11-07[Bug #19106] Normalize time at 24:00:00 with a timezone objectNobuyoshi Nakada
2022-10-11[DOC] use the local rdoc reference than the external URINobuyoshi Nakada
2022-09-03[DOC] Remove extra page-dir prefix to fix broken linkNobuyoshi Nakada
2022-09-03[DOC] Enhanced RDoc for Time (#6320)Burdette Lamar
Treats: #yday #dst? #zone #to_a #strftime Notes: Merged-By: BurdetteLamar <BurdetteLamar@Yahoo.com>
2022-09-02Enhanced RDoc for Tim[DOC] (#6319)Burdette Lamar
Notes: Merged-By: BurdetteLamar <BurdetteLamar@Yahoo.com>
2022-08-31[DOC] Enhanced RDoc for Time (#6308)Burdette Lamar
More on timezones. Notes: Merged-By: BurdetteLamar <BurdetteLamar@Yahoo.com>
2022-08-28[DOC] Enhanced RDoc for Time (#6294)Burdette Lamar
Notes: Merged-By: BurdetteLamar <BurdetteLamar@Yahoo.com>
2022-08-25[DOC] Enhanced RDoc for Time (#6277)Burdette Lamar
Deletes the :include: files in doc/time, which became no longer workable when @nobu pointed out that some (but not all) creator methods accept string values as well as integer-like values. Changes to methods: Time.utc Time.local Time.at Time.new Notes: Merged-By: BurdetteLamar <BurdetteLamar@Yahoo.com>
2022-08-26[DOC] Tell RDoc aliases of singleton classNobuyoshi Nakada
Since RDoc C parser cannot capture aliases which are using an expression other than a single variable as the class, use an intermediate variable for the singleton class.
2022-08-23[DOC] Remove extra page-dir prefixNobuyoshi Nakada
2022-08-22[DOC] Enhanced RDoc for Time (#6267)Burdette Lamar
Treats: #utc #getlocal #getutc #ctime #to_s #inspect Notes: Merged-By: BurdetteLamar <BurdetteLamar@Yahoo.com>
2022-08-22[DOC] Remove extra page-dir prefixNobuyoshi Nakada
2022-08-21[DOC] Enhanced RDoc for Time (#6255)Burdette Lamar
Treats: #utc #hash #localtime Notes: Merged-By: BurdetteLamar <BurdetteLamar@Yahoo.com>
2022-07-21Expand tabs [ci skip]Takashi Kokubun
[Misc #18891] Notes: Merged: https://github.com/ruby/ruby/pull/6094
2022-07-18[Bug #18922] Normalize time at 24:00:00 UTCNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/6146 Merged-By: nobu <nobu@ruby-lang.org>
2022-07-12[DOC] Enhanced RDoc for Time (#6118)Burdette Lamar
Treats: ::utc ::local #to_i #to_f #to_r #usec #nsec #subsec #<=> #eql? Notes: Merged-By: BurdetteLamar <BurdetteLamar@Yahoo.com>
2022-05-26Using TZMODE_SET_LOCALTIME macroS-H-GAMELINKS
Notes: Merged: https://github.com/ruby/ruby/pull/5937
2022-04-09[DOC]Some link prefix replaceS-H-GAMELINKS
Notes: Merged: https://github.com/ruby/ruby/pull/5783