summaryrefslogtreecommitdiff
path: root/time.c
AgeCommit message (Collapse)Author
2022-01-12Speed up and avoid kwarg hash alloc in Time.nowJohn Hawthorn
Previously Time.now was switched to use Time.new as it added support for the in: argument. Unfortunately because Class#new is a cfunc this requires always allocating a Hash. This commit switches Time.now back to using a builtin time_s_now. This avoids the extra Hash allocation and is about 3x faster. $ benchmark-driver -e './ruby;3.1::~/.rubies/ruby-3.1.0/bin/ruby;3.0::~/.rubies/ruby-3.0.2/bin/ruby' benchmark/time_now.yml Warming up -------------------------------------- Time.now 6.704M i/s - 6.710M times in 1.000814s (149.16ns/i, 328clocks/i) Time.now(in: "+09:00") 2.003M i/s - 2.112M times in 1.054330s (499.31ns/i) Calculating ------------------------------------- ./ruby 3.1 3.0 Time.now 7.693M 2.763M 6.394M i/s - 20.113M times in 2.614428s 7.278710s 3.145572s Time.now(in: "+09:00") 2.030M 1.260M 1.617M i/s - 6.008M times in 2.960132s 4.769378s 3.716537s Comparison: Time.now ./ruby: 7693129.7 i/s 3.0: 6394109.2 i/s - 1.20x slower 3.1: 2763282.5 i/s - 2.78x slower Time.now(in: "+09:00") ./ruby: 2029757.4 i/s 3.0: 1616652.3 i/s - 1.26x slower 3.1: 1259776.2 i/s - 1.61x slower Notes: Merged: https://github.com/ruby/ruby/pull/5429
2021-12-25Raise proper exception when month argument is not a nameNobuyoshi Nakada
https://bugs.ruby-lang.org/issues/17485#change-89871 Notes: Merged: https://github.com/ruby/ruby/pull/5344
2021-12-09Check month overflow when marshalNobuyoshi Nakada
https://hackerone.com/reports/1244185 Notes: Merged: https://github.com/ruby/ruby/pull/5238
2021-11-15Use `Primitive.mandatory_only?` for `Time.at`Koichi Sasada
Notes: Merged: https://github.com/ruby/ruby/pull/5112
2021-11-10Tentative fix of subsec to `Time.at` [Bug #18293]Nobuyoshi Nakada
2021-11-10Simplify default values of `Time.at` [Bug #18293]Nobuyoshi Nakada
2021-10-28Fix leap day with UTC offset [Bug #18274]Nobuyoshi Nakada
`struct vtm::year` is a Ruby integer instance, but not a C integer type. Notes: Merged: https://github.com/ruby/ruby/pull/5041
2021-10-14Prefer the reentrant versions of gmtime and localtimeNobuyoshi Nakada
2021-09-18Include the invalid value in invalid_utc_offset errorNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/4864
2021-09-16Remove unneeded ruby_reset_leap_second_info function declaration (#4824)S.H
Notes: Merged-By: nurse <naruse@airemix.jp>
2021-09-11Using RB_BIGNUM_TYPE_P macroS-H-GAMELINKS
Notes: Merged: https://github.com/ruby/ruby/pull/4805
2021-09-10include/ruby/internal/intern/time.h: add doxygen卜部昌平
Must not be a bad idea to improve documents. [ci skip] Notes: Merged: https://github.com/ruby/ruby/pull/4815
2021-09-05Replace RBOOL macroS-H-GAMELINKS
Notes: Merged: https://github.com/ruby/ruby/pull/4791
2021-08-02Using RBOOL macroS.H
Notes: Merged: https://github.com/ruby/ruby/pull/4695 Merged-By: nobu <nobu@ruby-lang.org>
2021-06-27Added macros for days in monthNobuyoshi Nakada
2021-06-27Shrink monthly tablesNobuyoshi Nakada
2021-06-22[Documentation] Fix typo, formatting in `time.c`Anton Rieder
Backticks do not result in code formatting. Notes: Merged: https://github.com/ruby/ruby/pull/4594
2021-06-18Make frozen Time Ractor-shareableNobuyoshi Nakada
2021-06-14time.c: Check if defined(RUBY_MSVCRT_VERSION) to build on SolarisYusuke Endoh
Fixes [Bug #17947]
2021-06-07timev.rb: moved class rdoc from time.cNobuyoshi Nakada
2021-04-29Update Time documentationBurdette Lamar
2021-04-01Refactored sub-seconds normalizationsNobuyoshi Nakada
* separated argument to `timespec2timew` from `timespec` to seconds and nano-seconds. * unified nano-seconds and micro-seconds normalizations. Notes: Merged: https://github.com/ruby/ruby/pull/4343 Merged-By: nobu <nobu@ruby-lang.org>
2021-02-19Remove mentions of Bignum in time.cJeremy Evans
Move section on internal details out of the class-level documentation, since users do not need to know that. Update it to use Integer(T_BIGNUM) instead of Bignum. Fixes [Misc #17580]
2021-02-16Parse "-00:00" as UTC for the round-trip [Feature #17544]Nobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/4075
2021-02-11Fixed time_t conversion modifiers for debugNobuyoshi Nakada
2021-02-10Compile debugging code for time alwaysNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/4168
2021-02-10Fixed the signature of find_time_numguess_getterNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/4168
2021-01-13Added `in:` timezone option to `Time.new` [Feature #17485]Nobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/4010
2021-01-13Allow UTC offset without colons per ISO-8601 [Bug #17504]Nobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/4020
2021-01-12Convert time component strings to integers more strictlyNobuyoshi Nakada
https://bugs.ruby-lang.org/issues/17485#change-89871
2021-01-12Show seconds of utc_offset if not zeroNobuyoshi Nakada
2020-12-31get_tmopt is no longer usedNobuyoshi Nakada
2020-12-31Moved Time.at to builtinNobuyoshi Nakada
2020-12-31Moved Time.now to builtinNobuyoshi Nakada
2020-12-31Moved time.rb to timev.rbNobuyoshi Nakada
2020-12-31Add time.rb as builtinNobuyoshi Nakada
2020-12-07Removed deprecated Time#succNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/3841
2020-11-28Subsecond of Time::tm should be 0Nobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/3821
2020-10-21Use rb_intern_const instead of rb_intern in Init functionsNobuyoshi Nakada
``` find . -name \*.o -exec nm {} + |& sed '/Init_.*\.rbimpl_id/!d;s/^.* b //;s/\.[1-9][0-9]*$//;s/\.rbimpl_id$//' | uniq ``` should be empty.
2020-10-21Don't redefine #rb_intern over and over againStefan Stüben
Notes: Merged: https://github.com/ruby/ruby/pull/3589
2020-07-28Fix Time#ceil when result should be the same as the receiverJeremy Evans
Fixes [Bug #17025] Notes: Merged: https://github.com/ruby/ruby/pull/3362
2020-07-28Use https instead of httpKazuhiro NISHIYAMA
2020-07-24Fix Time#to_a behavior with timezone [Bug #17046]S.H
Notes: Merged: https://github.com/ruby/ruby/pull/3355 Merged-By: nobu <nobu@ruby-lang.org>
2020-07-23Ensure time object meets a given condition [Bug #17042]Nobuyoshi Nakada
2020-07-23Merge pull request #3352 from S-H-GAMELINKS/bug/17042-strftimeS.H
Fix Time#strftime with timezone [Bug #17042] Notes: Merged-By: nobu <nobu@ruby-lang.org>
2020-07-21[DOC] time.c document updated.Tanaka Akira
* fraction -> subsecond for consistency with method name * The sentence, "A non-portable feature allows the offset to be negative on some systems.", is removed. Time before 1970 should work portably now. If localtime() doesn't work before 1970, Ruby should extrapolate it. * Time::new -> Time.new "::" for method call is not common notation now. * Time#to_i truncates subsecond * Time#to_f approximates a value in Time object * Time#to_r The sentence, "You can use this method to convert _time_ to another Epoch.", is removed. It is not clear because no actual example of "another Epoch" is given. * Time#usec truncates fraction of microseconds. * Time#nsec truncates fraction of nanoseconds. * describe Time#inspect shows subsecond since Ruby 2.7.0.
2020-07-12Fixed yday and wday with timezone [Bug #17024]Nobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/3312
2020-06-29find_time_t: reset status before goto卜部昌平
Notes: Merged: https://github.com/ruby/ruby/pull/3247
2020-06-29add UNREACHABLE_RETURN卜部昌平
Not every compilers understand that rb_raise does not return. When a function does not end with a return statement, such compilers can issue warnings. We would better tell them about reachabilities. Notes: Merged: https://github.com/ruby/ruby/pull/3247
2020-06-29time_mload: do not goto into a branch卜部昌平
I'm not necessarily against every goto in general, but jumping into a branch is definitely a bad idea. Better refactor. Notes: Merged: https://github.com/ruby/ruby/pull/3247