Issue2033

classification
Title: test_strptime fails: test_mar1_comes_after_feb29_even_when_omitting_the_year
Type: behaviour Severity: normal
Components: Library Versions: Jython 2.7
Milestone:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: jeff.allen Nosy List: Arfrever, jeff.allen, santa4nt
Priority: Keywords: patch

Created on 2013-03-24.00:54:29 by santa4nt, last changed 2013-12-02.20:36:07 by jeff.allen.

Files
File name Uploaded Description Edit Remove
issue2033.patch santa4nt, 2013-03-24.02:31:21 Fall back to _strptime if there is month but not year.
Messages
msg7973 (view) Author: Santoso Wijaya (santa4nt) Date: 2013-03-24.00:54:29
Root cause is this parse behavior:

Jython 2.7b1+ (default:cb99491f484e+, Mar 23 2013, 17:45:18) 
[Java HotSpot(TM) 64-Bit Server VM (Oracle Corporation)] on java1.7.0_17
Type "help", "copyright", "credits" or "license" for more information.
>>> from time import strptime
>>> strptime('Feb 29', '%b %d')
time.struct_time(tm_year=1970, tm_mon=3, tm_mday=1, tm_hour=0, tm_min=0, tm_sec=0, tm_wday=6, tm_yday=60, tm_isdst=-1)

Which, in turn, is caused by this Java behavior:

import java.text.SimpleDateFormat;

public class DateParse {
    public static void main(String[] args) throws Exception {
        SimpleDateFormat d = new SimpleDateFormat("MMM dd");
        System.out.println(d.parse("Feb 29").toString());
    }
}

$ java DateParse 
Sun Mar 01 00:00:00 PST 1970
msg7975 (view) Author: Santoso Wijaya (santa4nt) Date: 2013-03-24.02:31:21
Short of replacing SimpleDateFormat with our own subclass implementation, I can think of getting around it by falling back to _strptime.py implementation if we detect that there is a month specifier but not year.
msg8039 (view) Author: Santoso Wijaya (santa4nt) Date: 2013-06-05.20:36:54
Ping.
msg8186 (view) Author: Jeff Allen (jeff.allen) Date: 2013-12-01.17:04:18
Ping return ... thanks for this patch. I'm going to take a look at this and a few others. (We have some catching up to do.)
msg8190 (view) Author: Jeff Allen (jeff.allen) Date: 2013-12-02.20:36:06
Fixed in http://hg.python.org/jython/rev/5f7a81d261c8
History
Date User Action Args
2013-12-02 20:36:07jeff.allensetstatus: open -> closed
resolution: fixed
messages: + msg8190
2013-12-02 13:46:06Arfreversetnosy: + Arfrever
2013-12-01 17:04:19jeff.allensetassignee: jeff.allen
messages: + msg8186
nosy: + jeff.allen
2013-06-05 20:36:55santa4ntsetmessages: + msg8039
2013-03-24 02:31:21santa4ntsetfiles: + issue2033.patch
keywords: + patch
messages: + msg7975
2013-03-24 00:54:29santa4ntcreate