summaryrefslogtreecommitdiff
path: root/time.c
AgeCommit message (Collapse)Author
2021-04-05merge revision(s) ↵usa
276f6a225d18561cbe5282b798cb4e416c66079f,95bef7b69a6fb42687a6200b338060be307259f5: [Backport #17352] Don't double fractional seconds when passing timezone object to Time.new I found that fractional seconds were doubled when using the timezone feature of Time in Sequel's named_timezones extension (which uses TZInfo for the timezone object), and traced the problem to this code. There is no subsecx being modified in the utc_to_local call below this, and I'm not sure why you would want to add in the fractional seconds unless you assumed the timezone conversion would drop the existing fractional seconds (TZInfo doesn't drop fractional seconds). Subsecond of Time::tm should be 0 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_6@67934 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2021-03-02merge revision(s) 99a9c3fe: [Backport #17024]usa
Fixed yday and wday with timezone [Bug #17024] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_6@67911 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-12-18merge revision(s) ↵nagachika
d6a2bce64a7fa1099e507e1d36b5f1533f42f60f,c687be4bc01c9ce52ea990945d9304d6fe59fe9b: [Backport #16159] time.c (find_time_t): fix round-to-zero bug `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] Added a test for [Bug #16159] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_6@67836 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-24time.c: zone in fixoff modenobu
* time.c (time_set_utc_offset): reset zone when setting to fixoff mode. while previously TZMODE_SET_FIXOFF has reset it always, the zone is kept for loaded zone since r65025. [ruby-core:90627] [Bug #15439] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66520 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-17Range check is only for interavalnobu
* time.c (time_timespec): range check is only for time interval value if time_t is signed. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66421 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-16Refine error message for time intervalnobu
* time.c (time_timespec): Time interval value can be zero, not only positive. [ruby-dev:50709] [Bug #15420] From: shuujii (Shuji KOBAYASHI) <shuujii@gmail.com> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66418 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-15time.c: [DOC] improve docs for tz argument of Time.newstomar
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66410 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-13time.c: improve docs for Timestomar
* time.c: [DOC] fix typos, drop unnecessary `p' from code examples, add missing `#' for return values, other small improvements. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66389 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-06Prefer rb_check_arity when 0 or 1 argumentsnobu
Especially over checking argc then calling rb_scan_args just to raise an ArgumentError. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66238 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-04Prefer rb_check_arity when 0 or 1 argumentsnobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66179 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-28time.c: rescue find_timezone when loadingnobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66080 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-28Time.at in: tznobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66078 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-28Timezone at Time.atnobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66077 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-28Try Time.find_timezone to convert name to timezonenobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66076 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-28Try Time.find_timezone to loadnobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66075 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-25Normalize month-mday before finding epochnaruse
Especially over the year 2038, 30 Feb and so on may cause odd behavior on validating found epoch with given year-month-day [Bug #15340] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65974 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-04Hide Time::TM as Time::tmnobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65526 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-29time.c: [DOC] fix method names to refer class methods [ci skip]nobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65428 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-28time.c: added Time::TM#+ and Time::TM#-nobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65421 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-28time.c: ignore 7th argnobu
* time.c (tm_initialize): allow 7th argument as well as Time#initialize, but just ignore. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65420 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-28time.c: [DOC] add description and fix markups [ci skip]nobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65419 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-28time.c: [DOC] fix rdoc-ref [ci skip]nobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65413 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-28time.c: [DOC] about timezone arguemnt [ci skip]nobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65406 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-25time.c: benchmark recoverynobu
* time.c (time_localtime): check if `vtm.zone` is a simple zone name string before trying to call the conversion method. since r64952, `Time.getlocal` on UTC time has lost the performance about 45%, due to this call. the performance is about 90% of r64951 by avoiding it. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65360 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-23Let Time::TM share the implementation with Timenobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65321 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-22No longer subsec and isdst membersnobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65307 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-22Revert TM_IS_TIME to 1nobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65306 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-22Return fixed values at subsec, utc_offset, and isdstnobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65305 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-22time.c: optional arguments of Time::TM#initializenobu
* time.c (tm_initialize): arguments other than year are optional now as Time.new. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65296 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-13Prefer `rb_fstring_lit` over `rb_fstring_cstr`nobu
The former states explicitly that the argument must be a literal, and can optimize away `strlen` on all compilers. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65059 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-12Fix overwritten zone stringnobu
* time.c (zone_str): while rb_fstring_usascii and the family require that the argument string is never modified, tzname may point areas which will be discarded by calling tzset(). make a String then call rb_fstring to copy the zone name. when an ID equals TZ environment variable, its name string also has modified by changing tzname. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65035 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-12Initialize zonenobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65026 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-12Load as FIXOFF mode if zone is presentnobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65025 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-12Just copy tzmodenobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65024 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-08Timezone at Time#+ and Time#-nobu
* time.c (time_add): support for Timezone. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64958 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-08* expand tabs.svn
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64953 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-08Timezone support by Time [Feature #14850]nobu
* strftime.c (rb_strftime): support timezone object by `%z`. * time.c (time_init_1, time_new_timew, time_getlocaltime): accept timezone object as `off`. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64952 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-09-27Fix messages for too small yearnobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64866 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-09-12time.c split time_utc_or_localnobu
* time.c (time_utc_or_local): split into time_s_mkutc and time_s_mktime without utc flag. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64700 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-08-21rename an argument of calc_wday.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64494 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-08-15gmtimew_noleapsecond uses tables for mon and mday.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64380 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-08-12timegm_noleapsecond uses calc_tm_yday.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64327 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-08-08rename several internal macros in time.cakr
TIME_UTC_P -> TZMODE_UTC_P TIME_SET_UTC -> TZMODE_SET_UTC TIME_LOCALTIME_P -> TZMODE_LOCALTIME_P TIME_SET_LOCALTIME -> TZMODE_SET_LOCALTIME TIME_FIXOFF_P -> TZMODE_FIXOFF_P TIME_SET_FIXOFF -> TZMODE_SET_FIXOFF TIME_COPY_GMT -> TZMODE_COPY git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64230 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-08-08Update comment of tzmode [ci skip]kazu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64229 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-08-08Rename gmt field to tzmode in struct time_object.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64228 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-08-08Store String as zone in struct vtm.akr
This removes zone_table and use fstring instead. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64227 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-07-19renamed ruby_tz_update as ruby_tz_uptodate_pnobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63997 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-07-18reduce tzsetnobu
* time.c (rb_localtime_r): call tzset() only after TZ environment variable is changed. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63994 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-07-06Prefixed reset_leap_second_infonobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63864 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-07-05Re-apply r63848 (Optimize Time.utc)naruse
* Both timegmw and gmtimew ignores leap second if the timezone doesn't have leap seconds on the first call of init_leap_second_info() * Add Bug::Time.reset_leap_second_info for testing git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63857 b2dd03c8-39d4-4d8f-98ff-823fe69b080e