summaryrefslogtreecommitdiff
path: root/time.c
AgeCommit message (Collapse)Author
2020-03-09Clarify Time::at documentation for in: argumentzverok
Notes: Merged: https://github.com/ruby/ruby/pull/2950
2020-02-27Update docs for Time#at method [ci skip]प्रथमेश Sonpatki
Add docs about all possible options for the `in` argument. Notes: Merged: https://github.com/ruby/ruby/pull/2929 Merged-By: nobu <nobu@ruby-lang.org>
2020-02-10Don't refer Date in the document for Time.Tanaka Akira
2020-02-07more on NULL versus functions.卜部昌平
Function pointers are not void*. See also ce4ea956d24eab5089a143bba38126f2b11b55b6 8427fca49bd85205f5a8766292dd893f003c0e48
2020-01-29ruby_reset_timezone resets leap_second_info.Tanaka Akira
[Bug #15177]
2020-01-28Extract a function, ruby_reset_timezone().Tanaka Akira
Initial implementation of ruby_reset_timezone() assigns ruby_tz_uptodate_p to false.
2020-01-13Simplify obj2ubits checksJohn Hawthorn
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. Notes: Merged: https://github.com/ruby/ruby/pull/2808
2020-01-13Avoid rb_check_string_type in month_argJohn Hawthorn
This will usually receive a fixnum so we should check that first instead of the more expensive rb_check_string_type check. Notes: Merged: https://github.com/ruby/ruby/pull/2808
2020-01-13Store "UTC" and "" fstring as globals in time.cJohn Hawthorn
Notes: Merged: https://github.com/ruby/ruby/pull/2808
2019-12-26decouple internal.h headers卜部昌平
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). Notes: Merged: https://github.com/ruby/ruby/pull/2711
2019-12-24[DOC] Fix typo in Time#inspectMarcus Stollsteimer
2019-12-22Actualize Time#inspect docszverok
Notes: Merged: https://github.com/ruby/ruby/pull/2768
2019-12-20Fixed misspellingsNobuyoshi Nakada
Fixed misspellings reported at [Bug #16437], only in ruby and rubyspec.
2019-12-17Reduce tzset callsNobuyoshi Nakada
Set up-to-date flag always when calling tzset().
2019-12-17time.c (find_time_t): fix round-to-zero bugYusuke Endoh
`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]
2019-12-03fix typoKOSAKI Motohiro
2019-12-01Avoid unnecessary tzset() callKOSAKI Motohiro
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
2019-11-25Improve consistency of bool/true/falseKazuhiro NISHIYAMA
2019-11-25Set TRUE/FALSE to `bool ruby_tz_uptodate_p` instead of 1/FALSEKazuhiro NISHIYAMA
2019-11-18Deprecate taint/trust and related methods, and make the methods no-opsJeremy Evans
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. Notes: Merged: https://github.com/ruby/ruby/pull/2476
2019-11-13Check more likely condition first [Feature #16335]Nobuyoshi Nakada
2019-10-06time.c: Fix some bugs about WIDEVALUEYusuke Endoh
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.
2019-09-19Specify encoding explicitly for sprintfNARUSE, Yui
2019-09-19Separate Time#inspect from to_s and show subsec [Feature #15958]NARUSE, Yui
2019-09-10Support timeout for AddrinfoMasaki Matsushita
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.
2019-09-09Revert "Support timeout for Addrinfo"Masaki Matsushita
This reverts commit 6382f5cc91ac9e36776bc854632d9a1237250da7. test failed on Solaris.
2019-09-09Support timeout for AddrinfoMasaki Matsushita
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.
2019-08-27rb_rescue / rb_rescue2 now free from ANYARGS卜部昌平
After 5e86b005c0f2ef30df2f9906c7e2f3abefe286a2, I now think ANYARGS is dangerous and should be extinct. This commit deletes ANYARGS from rb_rescue / rb_rescue2, which revealed many arity / type mismatches.
2019-08-06Refine time_to_rNobuyoshi Nakada
* time.c (time_to_r): get rid canonicalize and uncanonicalize one-denominator rational, by rb_time_unmagnify_to_rational.
2019-08-03Predefine some IDsNobuyoshi Nakada
2019-07-29Document that Timezone argument for Time uses dst? if available [ci skip]Jeremy Evans
2019-07-27Initialize DST flagNobuyoshi Nakada
* time.c (zone_timelocal): initialize DST flag by asking the timezone object. [Bug #15988]
2019-07-17Expanded buf to copy at onceNobuyoshi Nakada
Build dumped string from base packed data and extended year at once. Although currently ruby_marshal_write_long() never writes more than 5 bytes per its format specification, allocate `sizeof(long)+1` for the sanitation.
2019-07-17Named the backward compatible dump sizeNobuyoshi Nakada
2019-07-15time.c (time_mdump): use another buffer for year_extendYusuke Endoh
ruby_marshal_write_long may write 9 bytes, but buf has only 8 bytes. So the buffer cannot be reused. This issue was found by Coverity Scan.
2019-07-14Add a /* fall through */ commentYusuke Endoh
2019-06-19Marshal distant past/futureNobuyoshi Nakada
[Feature #15160]
2019-05-24[DOC] Use Rational literals than to_r in examplesNobuyoshi Nakada
2019-05-24Hoisted out ndigits_denominatorNobuyoshi Nakada
* time.c (ndigits_denominator): calculate the denominator for digits.
2019-05-23* expand tabs.git
2019-05-23Add `Time#ceil`.manga_osyo
Closes: https://github.com/ruby/ruby/pull/2133
2019-05-18[DOC] Shorten examples for Time#{round,floor}Marcus Stollsteimer
2019-05-18[DOC] Improve documentation for Time#floorMarcus Stollsteimer
Use numbers that are more illustrative for #floor.
2019-05-04Add a pathologic checkNobuyoshi Nakada
2019-04-20* expand tabs.svn
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67633 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-04-20Add `Time#floor`nobu
[Feature #15653] [Fix GH-2092] From: manga_osyo <manga.osyo@gmail.com> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67632 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-04-19time.c: added in: option to Time.nownobu
* time.c (time_s_now): added in: option to Time.now as well as Time.at. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67613 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-01-20time.c: [DOC] small improvementstomar
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66884 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-01-13time.c: separate sign argumentnobu
* time.c (vtm_add_offset): separate sign argument to get rid of repeated negations. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66804 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-01-13time.c: do not set utc_offset in vtm_add_offsetnobu
* time.c (vtm_add_offset): just add offset to other components only. removed subtraction of utc_offset as it is overwritten always immediately in callers. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66803 b2dd03c8-39d4-4d8f-98ff-823fe69b080e