Project

General

Profile

Actions

Bug #14933

closed

Time.strptime with ordinal dates

Added by v49564 (Victor Bruley) over 6 years ago. Updated over 6 years ago.

Status:
Closed
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 1 (0 open1 closed)

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

Updated by nobu (Nobuyoshi Nakada) over 6 years ago

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

Updated by nobu (Nobuyoshi Nakada) over 6 years ago

  • Status changed from Open to Closed

Applied in changeset trunk|r64028.


time.rb: yday support

Actions

Also available in: Atom PDF

Like0
Like0Like0