[Bug time/24394] New: strptime %Ey mis-parses final year of era

dj at redhat dot com sourceware-bugzilla@sourceware.org
Thu Mar 28 04:13:00 GMT 2019


https://sourceware.org/bugzilla/show_bug.cgi?id=24394

            Bug ID: 24394
           Summary: strptime %Ey mis-parses final year of era
           Product: glibc
           Version: unspecified
            Status: NEW
          Severity: normal
          Priority: P2
         Component: time
          Assignee: unassigned at sourceware dot org
          Reporter: dj at redhat dot com
  Target Milestone: ---

If you call strftime in the ja_JP locale, for dates in the year of an era
transition but before the transition (i.e. Jan 1st to Jan 7th, 1989) with a %EY
format, it returns a string that fails to be parsed by strptime when passed
%EY.

The problem seems to be in strptime's %Ey handler (part of the era-specific
format):

                          match = (delta >= 0
                                   && delta < (((int64_t) era->stop_date[0]
                                                - (int64_t) era->start_date[0])
                                               * era->absolute_direction));

This seems to be a fencepost error, and "stop - start + 1" should be used to
include the stop_date's partial year.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


More information about the Glibc-bugs mailing list