Project

General

Profile

Actions

Bug #9836

closed

Bad Implementation of Time.strptime

Added by silverhammermba (Max Anselm) almost 10 years ago. Updated over 4 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-linux]
[ruby-core:62567]

Description

According to the documentation, Time.strptime "parses +date+ using Date._strptime and converts it to a Time object." However this conversion is extremely naive, using only certain fields return by Date._strptime and ignoring the rest (for example :wnum0).

This creates confusing and inconsistent behavior when compared to Date and DateTime's strptime methods.

For example:

puts Date.strptime('201418', "%Y%U")
=> 2014-05-04
puts DateTime.strptime('201418', "%Y%U")
=> 2014-05-04T00:00:00+00:00
puts Time.strptime('201418', "%Y%U")
=> 2014-01-01 00:00:00 -0500

Files

time-strptime.patch (2.05 KB) time-strptime.patch jeremyevans0 (Jeremy Evans), 08/11/2019 07:32 PM

Related issues 1 (0 open1 closed)

Related to Ruby master - Bug #14241: Time.strptime() doesn't support the directive "%W".Closedakr (Akira Tanaka)Actions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0