aboutsummaryrefslogtreecommitdiffstats
path: root/time.c
Commit message (Collapse)AuthorAgeFilesLines
* Removed deprecated Time#succNobuyoshi Nakada2020-12-071-35/+0
|
* Subsecond of Time::tm should be 0Nobuyoshi Nakada2020-11-281-0/+1
|
* Use rb_intern_const instead of rb_intern in Init functionsNobuyoshi Nakada2020-10-211-1/+1
| | | | | | | | | ``` find . -name \*.o -exec nm {} + |& sed '/Init_.*\.rbimpl_id/!d;s/^.* b //;s/\.[1-9][0-9]*$//;s/\.rbimpl_id$//' | uniq ``` should be empty.
* Don't redefine #rb_intern over and over againStefan Stüben2020-10-211-23/+20
|
* Fix Time#ceil when result should be the same as the receiverJeremy Evans2020-07-281-1/+4
| | | | Fixes [Bug #17025]
* Use https instead of httpKazuhiro NISHIYAMA2020-07-281-2/+2
|
* Fix Time#to_a behavior with timezone [Bug #17046]S.H2020-07-241-1/+1
|
* Ensure time object meets a given condition [Bug #17042]Nobuyoshi Nakada2020-07-231-15/+11
|
* Merge pull request #3352 from S-H-GAMELINKS/bug/17042-strftimeS.H2020-07-231-0/+4
| | | Fix Time#strftime with timezone [Bug #17042]
* [DOC] time.c document updated.Tanaka Akira2020-07-211-113/+130
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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.
* Fixed yday and wday with timezone [Bug #17024]Nobuyoshi Nakada2020-07-121-4/+9
|
* find_time_t: reset status before goto卜部昌平2020-06-291-0/+1
|
* add UNREACHABLE_RETURN卜部昌平2020-06-291-0/+1
| | | | | | 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.
* time_mload: do not goto into a branch卜部昌平2020-06-291-2/+4
| | | | | I'm not necessarily against every goto in general, but jumping into a branch is definitely a bad idea. Better refactor.
* indent [ci skip]卜部昌平2020-06-291-57/+57
|
* find_time_t: do not goto into a branch卜部昌平2020-06-291-29/+31
| | | | | I'm not necessarily against every goto in general, but jumping into a branch is definitely a bad idea. Better refactor.
* utc_offset_arg: do not goto into a branch卜部昌平2020-06-291-2/+3
| | | | | I'm not necessarily against every goto in general, but jumping into a branch is definitely a bad idea. Better refactor.
* vtm_add_offset: do not goto into a branch卜部昌平2020-06-291-2/+0
| | | | | I'm not necessarily against every goto in general, but jumping into a branch is definitely a bad idea. Better refactor.
* num_exact: do not goto into a branch卜部昌平2020-06-291-29/+19
| | | | | I'm not necessarily against every goto in general, but jumping into a branch is definitely a bad idea. Better refactor.
* Append subsec part instead of creating new stringNobuyoshi Nakada2020-06-031-1/+1
|
* sed -i 's|ruby/impl|ruby/internal|'卜部昌平2020-05-111-1/+1
| | | | To fix build failures.
* sed -i s|ruby/3|ruby/impl|g卜部昌平2020-05-111-1/+1
| | | | This shall fix compile errors.
* Merge pull request #2991 from shyouhei/ruby.h卜部昌平2020-04-081-1/+1
| | | Split ruby.h
* Clarify Time::at documentation for in: argumentzverok2020-03-091-2/+9
|
* Update docs for Time#at method [ci skip]प्रथमेश Sonpatki2020-02-271-1/+6
| | | Add docs about all possible options for the `in` argument.
* Don't refer Date in the document for Time.Tanaka Akira2020-02-101-2/+3
|
* more on NULL versus functions.卜部昌平2020-02-071-2/+2
| | | | | | Function pointers are not void*. See also ce4ea956d24eab5089a143bba38126f2b11b55b6 8427fca49bd85205f5a8766292dd893f003c0e48
* ruby_reset_timezone resets leap_second_info.Tanaka Akira2020-01-291-0/+2
| | | | [Bug #15177]
* Extract a function, ruby_reset_timezone().Tanaka Akira2020-01-281-0/+6
| | | | | Initial implementation of ruby_reset_timezone() assigns ruby_tz_uptodate_p to false.
* Simplify obj2ubits checksJohn Hawthorn2020-01-131-10/+6
| | | | | If this value is less than zero, then the mask check is guaranteed to fail as well, so we might as well rely on that.
* Avoid rb_check_string_type in month_argJohn Hawthorn2020-01-131-0/+4
| | | | | This will usually receive a fixnum so we should check that first instead of the more expensive rb_check_string_type check.
* Store "UTC" and "" fstring as globals in time.cJohn Hawthorn2020-01-131-6/+13
|
* decouple internal.h headers卜部昌平2019-12-261-11/+19
| | | | | | | | | | | | | | | | | | Saves comitters' daily life by avoid #include-ing everything from internal.h to make each file do so instead. This would significantly speed up incremental builds. We take the following inclusion order in this changeset: 1. "ruby/config.h", where _GNU_SOURCE is defined (must be the very first thing among everything). 2. RUBY_EXTCONF_H if any. 3. Standard C headers, sorted alphabetically. 4. Other system headers, maybe guarded by #ifdef 5. Everything else, sorted alphabetically. Exceptions are those win32-related headers, which tend not be self- containing (headers have inclusion order dependencies).
* [DOC] Fix typo in Time#inspectMarcus Stollsteimer2019-12-241-2/+2
|
* Actualize Time#inspect docszverok2019-12-221-5/+6
|
* Fixed misspellingsNobuyoshi Nakada2019-12-201-1/+1
| | | | Fixed misspellings reported at [Bug #16437], only in ruby and rubyspec.
* Reduce tzset callsNobuyoshi Nakada2019-12-171-7/+10
| | | | Set up-to-date flag always when calling tzset().
* time.c (find_time_t): fix round-to-zero bugYusuke Endoh2019-12-171-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | `find_time_t` did not work correctly for year older than the Epoch because it used C's integer division (which rounds negative to zero). For example, `TIme.new(1933)` returned a wrong time whose year is 1922 in Asia/Kuala_Lumpur because there is no 00:00:00 1st Jan. 1933 in the time zone. ``` $ TZ=Asia/Kuala_Lumpur ruby -e 'p Time.new(1933)' 1932-12-31 00:00:00 +0700 ``` This change fixes the issue by using `DIV` macro instead of `/`. Now `Time.new(1933)` returns a time in 1933. ``` $ TZ=Asia/Kuala_Lumpur ruby -e 'p Time.new(1933)' 1933-01-01 00:20:00 +0720 ``` [Bug #16159]
* fix typoKOSAKI Motohiro2019-12-031-1/+1
|
* Avoid unnecessary tzset() callKOSAKI Motohiro2019-12-011-8/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Akatsuki reported ENV['TZ'] = 'UTC' improved 7x-8x faster on following code. t = Time.now; 100000.times { Time.new(2019) }; Time.now - t https://hackerslab.aktsk.jp/2019/12/01/141551 commit 4bc1669127(reduce tzset) dramatically improved this situation. But still, TZ=UTC is faster than default. This patch removs unnecessary tzset() call completely. Performance check ---------------------- test program: t = Time.now; 100000.times { Time.new(2019) }; Time.now - t before: 0.387sec before(w/ TZ): 0.197sec after: 0.162sec after(w/ TZ): 0.165sec OK. Now, Time creation 2x faster *and* TZ=UTC doesn't improve anything. We can forget this hack completely. :) Side note: This patch slightly changes Time.new(t) behavior implicitly. Before this patch, it might changes default timezone implicitly. But after this patch, it doesn't. You need to reset TZ (I mean ENV['TZ'] = nil) explicitly. But I don't think this is big impact. Don't try to change /etc/localtime on runtime. Side note2: following test might be useful for testing "ENV['TZ'] = nil". ----------------------------------------- % cat <<'End' | sudo sh -s rm -f /etc/localtime-; cp -a /etc/localtime /etc/localtime- rm /etc/localtime; ln -s /usr/share/zoneinfo/Asia/Tokyo /etc/localtime ./ruby -e ' p Time.new(2000).zone # JST File.unlink("/etc/localtime"); File.symlink("/usr/share/zoneinfo/America/Los_Angeles", "/etc/localtime") p Time.new(2000).zone # JST (ruby does not follow /etc/localtime modification automatically) ENV["TZ"] = nil p Time.new(2000).zone # PST (ruby detect /etc/localtime modification) ' rm /etc/localtime; cp -a /etc/localtime- /etc/localtime; rm /etc/localtime- End
* Improve consistency of bool/true/falseKazuhiro NISHIYAMA2019-11-251-1/+1
|
* Set TRUE/FALSE to `bool ruby_tz_uptodate_p` instead of 1/FALSEKazuhiro NISHIYAMA2019-11-251-1/+1
|
* Deprecate taint/trust and related methods, and make the methods no-opsJeremy Evans2019-11-181-1/+0
| | | | | | This removes the related tests, and puts the related specs behind version guards. This affects all code in lib, including some libraries that may want to support older versions of Ruby.
* Check more likely condition first [Feature #16335]Nobuyoshi Nakada2019-11-131-1/+10
|
* time.c: Fix some bugs about WIDEVALUEYusuke Endoh2019-10-061-4/+4
| | | | | | | | WIDEVALUE differs from VALUE in 32bit platform, but some codes assume that they are the same. There is `#define STRUCT_WIDEVAL` mode to check the consistency. This change allows to build with STRUCT_WIDEVAL.
* Specify encoding explicitly for sprintfNARUSE, Yui2019-09-191-1/+1
|
* Separate Time#inspect from to_s and show subsec [Feature #15958]NARUSE, Yui2019-09-191-3/+48
|
* Support timeout for AddrinfoMasaki Matsushita2019-09-101-0/+6
| | | | | | | | | | | | Addrinfo.getaddrinfo and .foreach now accepts :timeout in seconds as a keyword argument. If getaddrinfo_a(3) is available, the timeout will be applied for name resolution. Otherwise, it will be ignored. Socket.tcp accepts :resolv_timeout to use this feature. This commit is retry of 6382f5cc91ac9e36776bc854632d9a1237250da7. Test was failed on Solaris machines which don't have "http" in /etc/services. In this commit, use "ssh" instead.
* Revert "Support timeout for Addrinfo"Masaki Matsushita2019-09-091-6/+0
| | | | | This reverts commit 6382f5cc91ac9e36776bc854632d9a1237250da7. test failed on Solaris.
* Support timeout for AddrinfoMasaki Matsushita2019-09-091-0/+6
| | | | | | | | Addrinfo.getaddrinfo and .foreach now accepts :timeout in seconds as a keyword argument. If getaddrinfo_a(3) is available, the timeout will be applied for name resolution. Otherwise, it will be ignored. Socket.tcp accepts :resolv_timeout to use this feature.