Issue #9836 has been updated by jeremyevans0 (Jeremy Evans).

File time-strptime.patch added

I tried updating the patch to apply to the master branch (it is attached).  It doesn't appear to handle `%W` correctly:

```ruby
str = Time.local(2019, 1, 30).strftime('%w %W %Y')
# => "3 04 2019"

Date.strptime(str, '%w %W %Y')
# => #<Date: 2019-01-30 ((2458514j,0s,0n),+0s,2299161j)>

Time.strptime(str, '%w %W %Y')
# => 2019-01-31 00:00:00 -0800
```

I think the approach I'm proposing in #14241 is simpler, by leaving the calculation to `Date.strptime`.

----------------------------------------
Bug #9836: Bad Implementation of Time.strptime
https://bugs.ruby-lang.org/issues/9836#change-80612

* Author: silverhammermba (Max Anselm)
* Status: Feedback
* Priority: Normal
* Assignee: 
* 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
```

---Files--------------------------------
time-strptime.patch (2.05 KB)


-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>