Ignore:
Timestamp:
20/10/10 21:23:29 (10 years ago)
Author:
pjkersha
Message:

0.5.1 Release - fixes:

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TI12-security/trunk/ndg_saml/ndg/saml/utils/__init__.py

    r7143 r7634  
    8181        # Workaround for seconds fraction as strptime doesn't seem able to deal 
    8282        # with this  
    83         strDateTimeFraction, strSecondsFraction = strDateTime.split('.') 
     83        dateTimeTuple = strDateTime.split('.') 
     84         
     85        # Seconds fraction may not be present - see 
     86        # http://www.w3.org/TR/xmlschema-2/#dateTime - explicitly test for ... 
     87        if len(dateTimeTuple) == 2: 
     88            strDateTimeFraction, strSecondsFraction = dateTimeTuple 
     89            secondsFraction = float("0." + strSecondsFraction.replace('Z', '')) 
     90        else: 
     91            strDateTimeFraction = dateTimeTuple[0].replace('Z', '') 
     92            secondsFraction = 0. 
     93             
    8494        dtValue = datetime.strptime(strDateTimeFraction, cls.DATETIME_FORMAT) 
    85         secondsFraction = float("0." + strSecondsFraction.replace('Z', '')) 
    8695        dtValue += timedelta(seconds=secondsFraction) 
     96         
    8797        return dtValue 
    8898 
Note: See TracChangeset for help on using the changeset viewer.