Project

General

Profile

Bug #14860

Time.strptime does not work with Julian dates using %j

Added by ajrkerr (Adam Kerr) over 1 year ago. Updated 11 months ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
[ruby-core:87545]

Description

Time.strptime does not appear to be handling Julian dates, it is defaulting the date to be whatever is provided as "now" (e.g. January 1). I believe this is because Time is calling Date._strptime which returns a hash with {:yday=> ...} and does not handle the yday keyword.

Found in 2.3.3, verified not working in 2.5.1.

require "time"
require "date"

### Works for Dates ###
parsed_date = Date.strptime("15300", "%y%j")
expected_date = Date.new(2015, 10, 27)
# Does not raise
raise "dates not equal" if expected_date != parsed_date


### Does not work for Time ###
parsed_time = Time.strptime("15300", "%y%j")
expected_time = Time.new(2015, 10, 27)
# Raises
raise "times not equal" if expected_time != parsed_time

Related issues

Related to Ruby master - Bug #15776: Difference between Time.parse behaviour between 2.6.0 and 2.6.1+RejectedActions
Has duplicate Ruby master - Bug #14933: Time.strptime with ordinal datesClosedActions

Associated revisions

Revision 728b75bc
Added by nobu (Nobuyoshi Nakada) over 1 year ago

time.rb: yday support

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

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64028 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 64028
Added by nobu (Nobuyoshi Nakada) over 1 year ago

time.rb: yday support

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

Revision 64028
Added by nobu (Nobuyoshi Nakada) over 1 year ago

time.rb: yday support

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

History

#1

Updated by nobu (Nobuyoshi Nakada) over 1 year ago

  • Has duplicate Bug #14933: Time.strptime with ordinal dates 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]
#3

Updated by nagachika (Tomoyuki Chikanaga) 11 months ago

  • Backport changed from 2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: UNKNOWN to 2.3: REQUIRED, 2.4: REQUIRED, 2.5: REQUIRED
#4

Updated by nobu (Nobuyoshi Nakada) 8 months ago

  • Related to Bug #15776: Difference between Time.parse behaviour between 2.6.0 and 2.6.1+ added

Also available in: Atom PDF