Project

General

Profile

Actions

Bug #15322

closed

Time.strptime does not support %3N, %6N, %9N

Added by okkez (okkez _) about 6 years ago. Updated about 6 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 2.5.3p105 (2018-10-18 revision 65156) [x86_64-linux]
[ruby-core:89899]

Description

Time.strptime("2018-11-20 17:11:22.123", "%Y-%m-%d %H:%M:%S.%3N")
# => raise ArgumentError: invalid strptime format - `%Y-%m-%d %H:%M:%S.%3N'
Time.strptime("2018-11-20 17:11:22.123456", "%Y-%m-%d %H:%M:%S.%6N")
# => raise ArgumentError: invalid strptime format - `%Y-%m-%d %H:%M:%S.%6N'
Time.strptime("2018-11-20 17:11:22.123456789", "%Y-%m-%d %H:%M:%S.%9N")
# => raise ArgumentError: invalid strptime format - `%Y-%m-%d %H:%M:%S.%9N'

But RDoc says that (https://docs.ruby-lang.org/en/2.5.0/Time.html#method-c-strptime):

%N
Fractional seconds digits, default is 9 digits (nanosecond)

  %3N
  millisecond (3 digits)

  %6N
  microsecond (6 digits)

  %9N
  nanosecond (9 digits)

%N works fine for this purpose.
I think we can remove %3N, %6N, and %9N from the document.

In fact, Fluentd users confuse when they read the document to configure Fluentd's parameter.

See also #11220


Files

fix-time-parse-format-doc.patch (572 Bytes) fix-time-parse-format-doc.patch okkez (okkez _), 11/20/2018 08:07 AM
Actions #1

Updated by okkez (okkez _) about 6 years ago

  • Subject changed from Time.parse does not support %3N, %6N, %9N to Time.strptime does not support %3N, %6N, %9N
  • Description updated (diff)

Updated by naruse (Yui NARUSE) about 6 years ago

You can commit it but ", default is 9 digits " should also be removed.

Updated by okkez (okkez _) about 6 years ago

Thank you for comments. I will commit the patch.

Actions #4

Updated by okkez (okkez _) about 6 years ago

  • Status changed from Open to Closed

Applied in changeset trunk|r66145.


time.rb: remove the unsupported formatting options from the document [ci skip]

Time.strptime does not support %3N, %6N, and %9N.

close [Bug #15322]

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0