From: ajrkerr@... Date: 2018-06-21T02:28:19+00:00 Subject: [ruby-core:87545] [Ruby trunk Bug#14860] Time.strptime does not work with Julian dates using %j Issue #14860 has been reported by ajrkerr (Adam Kerr). ---------------------------------------- Bug #14860: Time.strptime does not work with Julian dates using %j https://bugs.ruby-lang.org/issues/14860 * Author: ajrkerr (Adam Kerr) * Status: Open * Priority: Normal * Assignee: * Target version: * ruby -v: 2.5.1 * Backport: 2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: UNKNOWN ---------------------------------------- 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. ~~~ ruby 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 ~~~ -- https://bugs.ruby-lang.org/ Unsubscribe: