Project

General

Profile

Bug #14933

Time.strptime with ordinal dates

Added by v49564 (Victor Bruley) over 1 year ago. Updated over 1 year ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
ruby -v:
ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux]
[ruby-core:88062]

Description

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

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:

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

Related issues

Is duplicate of Ruby master - Bug #14860: Time.strptime does not work with Julian dates using %jClosedActions

History

#1

Updated by nobu (Nobuyoshi Nakada) over 1 year ago

  • Is duplicate of Bug #14860: Time.strptime does not work with Julian dates using %j added
#2

Updated by nobu (Nobuyoshi Nakada) over 1 year ago

  • Status changed from Open to Closed

Applied in changeset trunk|r64028.


time.rb: yday support

  • lib/time.rb (Time.make_time): added yday support. [ruby-core:87545] [Bug #14860]

Also available in: Atom PDF