Ignore:
Timestamp:
Mar 19, 2014, 11:31:01 PM (11 years ago)
Author:
dmik
Message:

python: Merge vendor 2.7.6 to trunk.

Location:
python/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • python/trunk

  • python/trunk/Lib/_strptime.py

    r2 r391  
    223223
    224224        Want possible matching values to be from longest to shortest.  This
    225         prevents the possibility of a match occuring for a value that also
     225        prevents the possibility of a match occurring for a value that also
    226226        a substring of a larger value that should have matched (e.g., 'abc'
    227227        matching when 'abcdef' should have been the match).
     
    327327        raise ValueError("unconverted data remains: %s" %
    328328                          data_string[found.end():])
    329     year = 1900
     329
     330    year = None
    330331    month = day = 1
    331332    hour = minute = second = fraction = 0
     
    426427                        tz = value
    427428                        break
     429    leap_year_fix = False
     430    if year is None and month == 2 and day == 29:
     431        year = 1904  # 1904 is first leap year of 20th century
     432        leap_year_fix = True
     433    elif year is None:
     434        year = 1900
    428435    # If we know the week of the year and what day of that week, we can figure
    429436    # out the Julian day of the year.
     
    447454    if weekday == -1:
    448455        weekday = datetime_date(year, month, day).weekday()
     456    if leap_year_fix:
     457        # the caller didn't supply a year but asked for Feb 29th. We couldn't
     458        # use the default of 1900 for computations. We set it back to ensure
     459        # that February 29th is smaller than March 1st.
     460        year = 1900
     461
    449462    return (time.struct_time((year, month, day,
    450463                              hour, minute, second,
Note: See TracChangeset for help on using the changeset viewer.