Issue #14933 has been reported by v49564 (Victor Bruley).

----------------------------------------
Bug #14933: Time.strptime with ordinal dates
https://bugs.ruby-lang.org/issues/14933

* Author: v49564 (Victor Bruley)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux]
* Backport: 2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: UNKNOWN
----------------------------------------
Using `Time`, I cannot parse an ordinal date (https://en.wikipedia.org/wiki/ISO_8601#Ordinal_dates).
It should work with `%j` according to the documentation: https://ruby-doc.org/stdlib-2.5.1/libdoc/time/rdoc/Time.html#method-c-strptime

~~~ ruby
require "time"
Time.strptime("2018-365", "%Y-%j")
 => 2018-01-01 00:00:00 +0100
~~~
I expect `2018-12-31 00:00:00 +0100`

It works using `DateTime`:
~~~ ruby
require "date"
DateTime.strptime("2018-365", "%Y-%j").to_time
 => 2018-12-31 00:00:00 +0000 
~~~




-- 
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>