[#62297] Re: [ruby-cvs:52906] nari:r45760 (trunk): * gc.c (gc_after_sweep): suppress unnecessary expanding heap. — Eric Wong <normalperson@...>
[email protected] wrote:
7 messages
2014/05/02
[#62307] Re: [ruby-cvs:52906] nari:r45760 (trunk): * gc.c (gc_after_sweep): suppress unnecessary expanding heap.
— SASADA Koichi <ko1@...>
2014/05/03
(2014/05/03 4:41), Eric Wong wrote:
[#62402] Re: [ruby-cvs:52906] nari:r45760 (trunk): * gc.c (gc_after_sweep): suppress unnecessary expanding heap.
— Eric Wong <normalperson@...>
2014/05/05
SASADA Koichi <[email protected]> wrote:
[#62523] [ruby-trunk - Feature #9632] [PATCH 0/2] speedup IO#close with linked-list from ccan — ko1@...
Issue #9632 has been updated by Koichi Sasada.
3 messages
2014/05/11
[#62556] doxygen (Re: Re: [ruby-trunk - Feature #9632] [PATCH 0/2] speedup IO#close with linked-list from ccan) — Tanaka Akira <akr@...>
2014-05-11 8:50 GMT+09:00 Eric Wong <[email protected]>:
3 messages
2014/05/13
[#62727] [RFC] vm_method.c (rb_method_entry_make): avoid freed me in m_tbl — Eric Wong <normalperson@...>
rb_unlink_method_entry may cause old_me to be swept before the new
7 messages
2014/05/24
[#63039] Re: [RFC] vm_method.c (rb_method_entry_make): avoid freed me in m_tbl
— SASADA Koichi <ko1@...>
2014/06/10
Hi,
[#63077] Re: [RFC] vm_method.c (rb_method_entry_make): avoid freed me in m_tbl
— Eric Wong <normalperson@...>
2014/06/10
SASADA Koichi <[email protected]> wrote:
[#63086] Re: [RFC] vm_method.c (rb_method_entry_make): avoid freed me in m_tbl
— SASADA Koichi <ko1@...>
2014/06/11
(2014/06/11 4:47), Eric Wong wrote:
[#63087] Re: [RFC] vm_method.c (rb_method_entry_make): avoid freed me in m_tbl
— Eric Wong <normalperson@...>
2014/06/11
SASADA Koichi <[email protected]> wrote:
[#62862] [RFC] README.EXT: document rb_gc_register_mark_object — Eric Wong <normalperson@...>
Any comment on officially supporting this as part of the C API?
5 messages
2014/05/30
[ruby-core:62576] [ruby-trunk - Bug #9836] Bad Implementation of Time.strptime
From:
nobu@...
Date:
2014-05-14 06:28:43 UTC
List:
ruby-core #62576
Issue #9836 has been updated by Nobuyoshi Nakada.
I guess the OP expects `%U` not to be ignored.
~~~diff
diff --git a/lib/time.rb b/lib/time.rb
index 3728fef..ec45767 100644
--- a/lib/time.rb
+++ b/lib/time.rb
@@ -194,13 +194,18 @@ class Time
LeapYearMonthDays = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] # :nodoc:
CommonYearMonthDays = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] # :nodoc:
- def month_days(y, m)
+ def month_days_of_year(y)
if ((y % 4 == 0) && (y % 100 != 0)) || (y % 400 == 0)
- LeapYearMonthDays[m-1]
+ LeapYearMonthDays
else
- CommonYearMonthDays[m-1]
+ CommonYearMonthDays
end
end
+ private :month_days_of_year
+
+ def month_days(y, m)
+ month_days_of_year(y)[m-1]
+ end
private :month_days
def apply_offset(year, mon, day, hour, min, sec, off)
@@ -432,7 +437,34 @@ class Time
else
year = d[:year]
year = yield(year) if year && block_given?
- t = make_time(date, year, d[:mon], d[:mday], d[:hour], d[:min], d[:sec], d[:sec_fraction], d[:zone], now)
+ mon = d[:mon]
+ mday = d[:mday]
+ unless mon and mday
+ case
+ when (w = d[:wnum0]) # %U
+ range = 0..53
+ mday = +1
+ when (w = d[:wnum1]) # %W
+ range = 0..53
+ mday = +2
+ when (w = d[:cweek]) # %V
+ range = 1..53
+ mday = -6
+ end
+ if mday
+ raise ArgumentError, "invalid date" unless range.cover?(w)
+ t = make_time(date, year, 1, 1, nil, nil, nil, nil, d[:zone], now)
+ mday += w * 7 - t.wday
+ if w = d[:wday] || d[:cwday]
+ mday += w
+ end
+ month_days_of_year(t.year).each_with_index do |n, m|
+ break mon = m+1 if mday <= n
+ mday -= n
+ end
+ end
+ end
+ t = make_time(date, year, mon, mday, d[:hour], d[:min], d[:sec], d[:sec_fraction], d[:zone], now)
end
t
end
~~~
----------------------------------------
Bug #9836: Bad Implementation of Time.strptime
https://bugs.ruby-lang.org/issues/9836#change-46720
* Author: Max Anselm
* Status: Feedback
* Priority: Normal
* Assignee:
* Category:
* Target version:
* ruby -v: ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-linux]
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN
----------------------------------------
According to the documentation, `Time.strptime` "parses +date+ using `Date._strptime` and converts it to a Time object." However this conversion is extremely naive, using only certain fields return by `Date._strptime` and ignoring the rest (for example `:wnum0`).
This creates confusing and inconsistent behavior when compared to `Date` and `DateTime`'s `strptime` methods.
For example:
```
puts Date.strptime('201418', "%Y%U")
=> 2014-05-04
puts DateTime.strptime('201418', "%Y%U")
=> 2014-05-04T00:00:00+00:00
puts Time.strptime('201418', "%Y%U")
=> 2014-01-01 00:00:00 -0500
```
--
https://bugs.ruby-lang.org/