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

608 Коммитов

Автор SHA1 Сообщение Дата
Tanaka Akira 338c5b8c1d Extract a function, ruby_reset_timezone().
Initial implementation of ruby_reset_timezone()
assigns ruby_tz_uptodate_p to false.
2020-01-28 23:40:25 +09:00
John Hawthorn 91601dcc6a Simplify obj2ubits checks
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.
2020-01-13 13:58:23 -08:00
John Hawthorn 5f3189474c Avoid rb_check_string_type in month_arg
This will usually receive a fixnum so we should check that first instead
of the more expensive rb_check_string_type check.
2020-01-13 13:58:23 -08:00
John Hawthorn c2e45422f7 Store "UTC" and "" fstring as globals in time.c 2020-01-13 13:58:23 -08:00
卜部昌平 5e22f873ed decouple 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).
2019-12-26 20:45:12 +09:00
Marcus Stollsteimer ceba5b7088 [DOC] Fix typo in Time#inspect 2019-12-24 21:50:27 +01:00
zverok 4988843188 Actualize Time#inspect docs 2019-12-22 23:17:39 +09:00
Nobuyoshi Nakada db16629008
Fixed misspellings
Fixed misspellings reported at [Bug #16437], only in ruby and rubyspec.
2019-12-20 09:32:42 +09:00
Nobuyoshi Nakada ebe5b66ca8
Reduce tzset calls
Set up-to-date flag always when calling tzset().
2019-12-17 10:48:17 +09:00
Yusuke Endoh d6a2bce64a 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]
2019-12-17 10:36:20 +09:00
KOSAKI Motohiro 7f2cd2ae6f fix typo 2019-12-03 10:50:16 +00:00
KOSAKI Motohiro 4d7a6d04b2 Avoid unnecessary tzset() call
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-12-01 16:34:26 +00:00
Kazuhiro NISHIYAMA 09e76e9828
Improve consistency of bool/true/false 2019-11-25 15:09:09 +09:00
Kazuhiro NISHIYAMA 5c6235a83c
Set TRUE/FALSE to `bool ruby_tz_uptodate_p` instead of 1/FALSE 2019-11-25 12:10:05 +09:00
Jeremy Evans ffd0820ab3 Deprecate taint/trust and related methods, and make the methods no-ops
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.
2019-11-18 01:00:25 +02:00
Nobuyoshi Nakada e7ea6e078f
Check more likely condition first [Feature #16335] 2019-11-13 16:54:31 +09:00
Yusuke Endoh 2409667aa2 time.c: Fix some bugs about WIDEVALUE
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-10-06 11:39:01 +09:00
NARUSE, Yui cbf405fec4 Specify encoding explicitly for sprintf 2019-09-19 20:45:24 +09:00
NARUSE, Yui 5208c431be Separate Time#inspect from to_s and show subsec [Feature #15958] 2019-09-19 20:20:15 +09:00
Masaki Matsushita 0e9d56f5e7 Support timeout for Addrinfo
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 6382f5cc91.
Test was failed on Solaris machines which don't have "http" in
/etc/services. In this commit, use "ssh" instead.
2019-09-10 10:10:59 +09:00
Masaki Matsushita c4efbf663e Revert "Support timeout for Addrinfo"
This reverts commit 6382f5cc91.
test failed on Solaris.
2019-09-09 20:34:51 +09:00
Masaki Matsushita 6382f5cc91 Support timeout for Addrinfo
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-09-09 14:34:05 +09:00
卜部昌平 5c7c2d9951 rb_rescue / rb_rescue2 now free from ANYARGS
After 5e86b005c0, 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-27 15:52:26 +09:00
Nobuyoshi Nakada 0ed298f382
Refine time_to_r
* time.c (time_to_r): get rid canonicalize and uncanonicalize
  one-denominator rational, by rb_time_unmagnify_to_rational.
2019-08-06 23:39:14 +09:00
Nobuyoshi Nakada 4ea5c5610a
Predefine some IDs 2019-08-03 10:18:39 +09:00
Jeremy Evans 177731aadf Document that Timezone argument for Time uses dst? if available [ci skip] 2019-07-29 11:06:43 -07:00
Nobuyoshi Nakada 149e414ed5
Initialize DST flag
* time.c (zone_timelocal): initialize DST flag by asking the
  timezone object.  [Bug #15988]
2019-07-27 12:41:33 +09:00
Nobuyoshi Nakada f487e5b7a4
Expanded buf to copy at once
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-17 08:34:19 +09:00
Nobuyoshi Nakada ed2f2b4f98
Named the backward compatible dump size 2019-07-17 07:28:17 +09:00
Yusuke Endoh d37da60128 time.c (time_mdump): use another buffer for year_extend
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-15 06:44:16 +09:00
Yusuke Endoh 219643c075 Add a /* fall through */ comment 2019-07-14 14:28:01 +09:00
Nobuyoshi Nakada e690df1f1e
Marshal distant past/future
[Feature #15160]
2019-06-19 15:26:53 +09:00
Nobuyoshi Nakada 45ad375acc
[DOC] Use Rational literals than to_r in examples 2019-05-24 16:10:10 +09:00
Nobuyoshi Nakada 1a4080cb0a
Hoisted out ndigits_denominator
* time.c (ndigits_denominator): calculate the denominator for
  digits.
2019-05-24 15:16:19 +09:00
git 0b4d51b055 * expand tabs. 2019-05-23 22:39:54 +09:00
manga_osyo f5415a95ce
Add `Time#ceil`.
Closes: https://github.com/ruby/ruby/pull/2133
2019-05-23 22:30:19 +09:00
Marcus Stollsteimer 60de17258b [DOC] Shorten examples for Time#{round,floor} 2019-05-18 13:06:49 +02:00
Marcus Stollsteimer cc0e460bcc [DOC] Improve documentation for Time#floor
Use numbers that are more illustrative for #floor.
2019-05-18 13:06:10 +02:00
Nobuyoshi Nakada b9e52db283
Add a pathologic check 2019-05-04 22:00:22 +09:00
svn 5d9acf07fb * expand tabs.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67633 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-04-20 05:00:45 +00:00
nobu 1686c0d470 Add `Time#floor`
[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-20 05:00:43 +00:00
nobu 4dd1cf3b27 time.c: added in: option to Time.now
* 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-04-19 08:53:40 +00:00
stomar 6833fbcfaf time.c: [DOC] small improvement
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66884 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-01-20 15:04:41 +00:00
nobu 665d9a4331 time.c: separate sign argument
* 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-13 04:36:45 +00:00
nobu 019c891508 time.c: do not set utc_offset in vtm_add_offset
* 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
2019-01-13 03:31:01 +00:00
nobu 347f3f30d6 time.c: update error message for invalid utc_offset
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66763 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-01-09 13:58:51 +00:00
nobu 8371a9a4ce time.c: support military time zone names
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66747 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-01-07 07:03:23 +00:00
nobu 4f9ab3a01a time.c: UTC and Z timezones should be utc
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66746 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-01-07 06:59:46 +00:00
nobu d747ecc0c4 time.c: zone in fixoff mode
* 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-24 01:46:48 +00:00
nobu 95fbd87fab Range check is only for interaval
* 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-17 00:43:40 +00:00
nobu 9446db408c Refine error message for time interval
* 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-16 12:55:59 +00:00
stomar 52a71df01b time.c: [DOC] improve docs for tz argument of Time.new
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66410 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-15 21:28:34 +00:00
stomar bd78a07f46 time.c: improve docs for Time
* 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-13 22:41:44 +00:00
nobu 98e65d9d92 Prefer rb_check_arity when 0 or 1 arguments
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-06 07:49:24 +00:00
nobu 4b85e88174 Prefer rb_check_arity when 0 or 1 arguments
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66179 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-04 02:24:15 +00:00
nobu 4471d4a3e5 time.c: rescue find_timezone when loading
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66080 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-28 14:08:35 +00:00
nobu ab73b30539 Time.at in: tz
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66078 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-28 14:08:33 +00:00
nobu bdfc701b85 Timezone at Time.at
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66077 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-28 14:08:32 +00:00
nobu 337b4b6344 Try Time.find_timezone to convert name to timezone
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66076 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-28 14:08:31 +00:00
nobu fe08f99e93 Try Time.find_timezone to load
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66075 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-28 14:08:30 +00:00
naruse 2c652768a8 Normalize month-mday before finding epoch
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-25 16:23:18 +00:00
nobu f167ff47a6 Hide Time::TM as Time::tm
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65526 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-04 02:09:01 +00:00
nobu 5bb1f4e73f time.c: [DOC] fix method names to refer class methods [ci skip]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65428 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-29 08:11:25 +00:00
nobu b361c8e3d5 time.c: added Time::TM#+ and Time::TM#-
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65421 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-28 12:05:19 +00:00
nobu d59ad98f6a time.c: ignore 7th arg
* 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-28 12:05:18 +00:00
nobu c4be18c28b time.c: [DOC] add description and fix markups [ci skip]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65419 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-28 12:05:17 +00:00
nobu 7eda588d66 time.c: [DOC] fix rdoc-ref [ci skip]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65413 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-28 05:53:57 +00:00
nobu 934e3e0e12 time.c: [DOC] about timezone arguemnt [ci skip]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65406 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-28 04:00:26 +00:00
nobu 4c875b6e66 time.c: benchmark recovery
* 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-25 00:36:23 +00:00
nobu fc3b500fb1 Let Time::TM share the implementation with Time
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65321 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-23 12:43:07 +00:00
nobu 6fdbf5a804 No longer subsec and isdst members
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65307 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-22 14:02:59 +00:00
nobu 0bed6345ce Revert TM_IS_TIME to 1
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65306 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-22 13:56:41 +00:00
nobu 385b772149 Return fixed values at subsec, utc_offset, and isdst
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65305 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-22 13:53:20 +00:00
nobu 8747974d4b time.c: optional arguments of Time::TM#initialize
* 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-22 01:25:29 +00:00
nobu fa8b08b424 Prefer `rb_fstring_lit` over `rb_fstring_cstr`
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-13 09:59:22 +00:00
nobu 1821e9f4dc Fix overwritten zone string
* 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-12 15:48:06 +00:00
nobu ade73091cb Initialize zone
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65026 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-12 02:49:39 +00:00
nobu 75ac8e866b Load as FIXOFF mode if zone is present
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65025 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-12 02:25:38 +00:00
nobu 093398f979 Just copy tzmode
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65024 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-12 02:25:37 +00:00
nobu fcf308e5fc Timezone at Time#+ and Time#-
* 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 04:03:32 +00:00
svn b8fbe8b59f * expand tabs.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64953 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-08 02:35:33 +00:00
nobu ee58c638b8 Timezone support by Time [Feature #14850]
* 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-10-08 02:35:31 +00:00
nobu 0e3e0f8249 Fix messages for too small year
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64866 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-09-27 10:22:08 +00:00
nobu 351b8a322e time.c split time_utc_or_local
* 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-09-12 14:37:51 +00:00
akr efb002cd7a rename an argument of calc_wday.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64494 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-08-21 14:40:18 +00:00
akr 3d3ff9f324 gmtimew_noleapsecond uses tables for mon and mday.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64380 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-08-15 14:24:44 +00:00
akr 8507904385 timegm_noleapsecond uses calc_tm_yday.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64327 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-08-12 16:45:02 +00:00
akr 4078be54ad rename several internal macros in time.c
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-08 12:48:58 +00:00
kazu 0f904ff1fc Update comment of tzmode [ci skip]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64229 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-08-08 11:50:39 +00:00
akr b81a33263a Rename gmt field to tzmode in struct time_object.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64228 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-08-08 10:39:31 +00:00
akr 277cedb84c Store String as zone in struct vtm.
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-08-08 10:00:43 +00:00
nobu 5ad205b81d renamed ruby_tz_update as ruby_tz_uptodate_p
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63997 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-07-19 11:22:03 +00:00
nobu 4bc1669127 reduce tzset
* 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-18 10:30:41 +00:00
nobu 33354d2928 Prefixed reset_leap_second_info
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63864 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-07-06 01:40:04 +00:00
naruse 6538f67d4d Re-apply r63848 (Optimize Time.utc)
* 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
2018-07-05 11:43:42 +00:00
naruse bd9a78a0fe Revert "Optimize Time.utc"
This reverts commit r63848.
It breaks tests.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63849 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-07-04 10:59:36 +00:00
naruse dda048381f Optimize Time.utc
Time.utc uses timegmw() and it uses leap second information.
If the given time is larger than known_leap_seconds_limit, it calls
find_time_t, which uses localtime(3) and calls stat(2) in it.

This patch avoid it by setting known_leap_seconds_limit to 0 if the timezone doesn't have leapsecond information (if no leap second is found "now", I assume the timezone doesn't have leapsecond information).

Before:
% time ./miniruby --disable-gem -e'time = Time.now; year = time.year; month = time.month; day = time.day; hour = time.hour; min = time.min; sec = time.sec + time.subsec; i = 0; while i < 100000; ::Time.utc(year, month, day, hour, min, sec); i += 1; end'
./miniruby --disable-gem   0.35s user 0.19s system 99% cpu 0.542 total

After:
% time ./miniruby --disable-gem -e'time = Time.now; year = time.year; month = time.month; day = time.day; hour = time.hour; min = time.min; sec = time.sec + time.subsec; i = 0; while i < 100000; ::Time.utc(year, month, day, hour, min, sec); i += 1; end'
./miniruby --disable-gem   0.23s user 0.00s system 99% cpu 0.233 total

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63848 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-07-04 10:06:51 +00:00
nobu 482bbde6e2 time.c: [DOC] Time#localtime
* time.c: state that Time#localtime does nothing when nothing
  changes.  [ruby-core:87675] [Bug #14880]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63823 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-07-02 07:46:38 +00:00
normal 218b8324bb time.c (num_exact): use predefined IDs
No need to waste space on "to_r" and "to_int" which are
predefined in defs/id.def

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62006 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-22 03:04:26 +00:00
normal 8a6c76b510 time.c: constify compat_* tables
compat_common_month_table and compat_leap_month_table should
not be writable.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62005 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-22 00:40:11 +00:00