Граф коммитов

624 Коммитов

Автор SHA1 Сообщение Дата
S-H-GAMELINKS 5b467400d2 [DOC]Some link prefix replace 2022-04-09 17:43:46 +09:00
Nobuyoshi Nakada 32f356e84a
Fix a typo of macro name
When the date is 28 Feb in the local timezone and 27 in the UTC,
the leap second info is wrongly calculated, and the Time for 1 Mar
created with a timezone resulted in an invalid date, 30 Feb.
2022-02-28 13:29:18 +09:00
John Hawthorn 2f71f6bb82 Speed up and avoid kwarg hash alloc in Time.now
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
2022-01-12 12:55:14 -08:00
Nobuyoshi Nakada 0867b638af Raise proper exception when month argument is not a name
https://bugs.ruby-lang.org/issues/17485#change-89871
2021-12-25 18:03:50 +09:00
Nobuyoshi Nakada da652e1827
Check month overflow when marshal
https://hackerone.com/reports/1244185
2021-12-09 21:51:39 +09:00
Koichi Sasada 2a3d5d661c Use `Primitive.mandatory_only?` for `Time.at` 2021-11-15 15:58:56 +09:00
Nobuyoshi Nakada 8bcff5604b
Tentative fix of subsec to `Time.at` [Bug #18293] 2021-11-10 18:14:14 +09:00
Nobuyoshi Nakada 83bdc2f00c
Simplify default values of `Time.at` [Bug #18293] 2021-11-10 17:42:18 +09:00
Nobuyoshi Nakada 1d666ed50f Fix leap day with UTC offset [Bug #18274]
`struct vtm::year` is a Ruby integer instance, but not a C integer
type.
2021-10-28 14:45:19 +09:00
Nobuyoshi Nakada e057b9eea9
Prefer the reentrant versions of gmtime and localtime 2021-10-14 23:44:15 +09:00
Nobuyoshi Nakada ec4ecb6d6d Include the invalid value in invalid_utc_offset error 2021-09-18 18:03:54 +09:00
S.H 68bd5626c3
Remove unneeded ruby_reset_leap_second_info function declaration (#4824) 2021-09-16 13:21:06 +09:00
S-H-GAMELINKS 032534dbdf Using RB_BIGNUM_TYPE_P macro 2021-09-11 09:13:24 +09:00
卜部昌平 a88bd246ca include/ruby/internal/intern/time.h: add doxygen
Must not be a bad idea to improve documents. [ci skip]
2021-09-10 20:00:06 +09:00
S-H-GAMELINKS bdd6d8746f Replace RBOOL macro 2021-09-05 23:01:27 +09:00
S.H 378e8cdad6
Using RBOOL macro 2021-08-02 12:06:44 +09:00
Nobuyoshi Nakada bf789af28a
Added macros for days in month 2021-06-27 08:37:45 +09:00
Nobuyoshi Nakada 1fd8b6f2b9
Shrink monthly tables 2021-06-27 08:37:42 +09:00
Anton Rieder bce0021f75 [Documentation] Fix typo, formatting in `time.c`
Backticks do not result in code formatting.
2021-06-22 20:51:57 +09:00
Nobuyoshi Nakada bdeaa60e7b
Make frozen Time Ractor-shareable 2021-06-18 11:58:15 +09:00
Yusuke Endoh 688b217706 time.c: Check if defined(RUBY_MSVCRT_VERSION) to build on Solaris
Fixes [Bug #17947]
2021-06-14 10:40:41 +09:00
Nobuyoshi Nakada c741ea0be7
timev.rb: moved class rdoc from time.c 2021-06-07 20:44:05 +09:00
Burdette Lamar 6ee55455a8 Update Time documentation 2021-04-29 19:58:15 -07:00
Nobuyoshi Nakada a5567350f7
Refactored sub-seconds normalizations
* separated argument to `timespec2timew` from `timespec` to seconds and
  nano-seconds.

* unified nano-seconds and micro-seconds normalizations.
2021-04-01 12:00:10 +09:00
Jeremy Evans b51e5c2370 Remove mentions of Bignum in time.c
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-19 08:30:11 -08:00
Nobuyoshi Nakada 296a2cab07 Parse "-00:00" as UTC for the round-trip [Feature #17544] 2021-02-16 20:34:23 +09:00
Nobuyoshi Nakada aea40f44aa
Fixed time_t conversion modifiers for debug 2021-02-11 23:53:29 +09:00
Nobuyoshi Nakada 4b6347ab39 Compile debugging code for time always 2021-02-10 19:45:14 +09:00
Nobuyoshi Nakada ef59a781d7 Fixed the signature of find_time_numguess_getter 2021-02-10 19:45:14 +09:00
Nobuyoshi Nakada 4b15caee8f
Added `in:` timezone option to `Time.new` [Feature #17485] 2021-01-13 18:15:50 +09:00
Nobuyoshi Nakada 9441f3f970 Allow UTC offset without colons per ISO-8601 [Bug #17504] 2021-01-13 16:37:59 +09:00
Nobuyoshi Nakada 1eb8eb55c2
Convert time component strings to integers more strictly
https://bugs.ruby-lang.org/issues/17485#change-89871
2021-01-12 17:24:43 +09:00
Nobuyoshi Nakada b017848f8a
Show seconds of utc_offset if not zero 2021-01-12 17:00:14 +09:00
Nobuyoshi Nakada 18ea81fd2c
get_tmopt is no longer used 2020-12-31 17:25:07 +09:00
Nobuyoshi Nakada 77e7082e82
Moved Time.at to builtin 2020-12-31 17:25:07 +09:00
Nobuyoshi Nakada 9101597d05
Moved Time.now to builtin 2020-12-31 17:25:07 +09:00
Nobuyoshi Nakada 93735f8fc0
Moved time.rb to timev.rb 2020-12-31 17:23:37 +09:00
Nobuyoshi Nakada d5fb51d2d3
Add time.rb as builtin 2020-12-31 15:19:06 +09:00
Nobuyoshi Nakada 7817a438eb Removed deprecated Time#succ 2020-12-07 18:38:59 +09:00
Nobuyoshi Nakada 95bef7b69a Subsecond of Time::tm should be 0 2020-11-28 15:41:41 +09:00
Nobuyoshi Nakada 5a77e90fe8
Use rb_intern_const instead of rb_intern in Init functions
```
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-21 12:46:53 +09:00
Stefan Stüben 8c2e5bbf58 Don't redefine #rb_intern over and over again 2020-10-21 12:45:18 +09:00
Jeremy Evans 520a734ad9 Fix Time#ceil when result should be the same as the receiver
Fixes [Bug #17025]
2020-07-28 12:53:37 -07:00
Kazuhiro NISHIYAMA 946cd6c534
Use https instead of http 2020-07-28 19:51:54 +09:00
S.H 2735da2039
Fix Time#to_a behavior with timezone [Bug #17046] 2020-07-24 20:17:31 +09:00
Nobuyoshi Nakada caf565f7bf
Ensure time object meets a given condition [Bug #17042] 2020-07-23 11:52:33 +09:00
S.H afacf85e44
Merge pull request #3352 from S-H-GAMELINKS/bug/17042-strftime
Fix Time#strftime with timezone [Bug #17042]
2020-07-23 11:35:20 +09:00
Tanaka Akira 48eb1ad2c3 [DOC] time.c document updated.
* 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-21 20:28:36 +09:00
Nobuyoshi Nakada 99a9c3fe2e
Fixed yday and wday with timezone [Bug #17024] 2020-07-12 21:58:13 +09:00
卜部昌平 da8af471fb find_time_t: reset status before goto 2020-06-29 11:05:41 +09:00