Exemple #1
0
def date_isoformat(tdate, format=DATE_EXT_COMPLETE, yeardigits=4):
    '''
    Format date strings.

    This method is just a wrapper around isodate.isostrf.strftime and uses
    Date-Extended-Complete as default format.
    '''
    return strftime(tdate, format, yeardigits)
Exemple #2
0
def time_isoformat(ttime, format=TIME_EXT_COMPLETE + TZ_EXT):
    '''
    Format time strings.

    This method is just a wrapper around isodate.isostrf.strftime and uses
    Time-Extended-Complete with extended time zone as default format.
    '''
    return strftime(ttime, format)
def datetime_isoformat(tdt, format=DATE_EXT_COMPLETE + 'T' +
                       TIME_EXT_COMPLETE + TZ_EXT):
    '''
    Format datetime strings.

    This method is just a wrapper around isodate.isostrf.strftime and uses
    Extended-Complete as default format.
    '''
    return strftime(tdt, format)
Exemple #4
0
def datetime_isoformat(tdt,
                       format=DATE_EXT_COMPLETE + 'T' + TIME_EXT_COMPLETE +
                       TZ_EXT):
    '''
    Format datetime strings.

    This method is just a wrapper around isodate.isostrf.strftime and uses
    Extended-Complete as default format.
    '''
    return strftime(tdt, format)
Exemple #5
0
def duration_isoformat(tduration, format=D_DEFAULT):
    '''
    Format duration strings.

    This method is just a wrapper around isodate.isostrf.strftime and uses
    P%P (D_DEFAULT) as default format.
    '''
    # TODO: implement better decision for negative Durations.
    #       should be done in Duration class in consistent way with timedelta.
    if (((isinstance(tduration, Duration) and
          (tduration.years < 0 or tduration.months < 0
           or tduration.tdelta < timedelta(0))) or
         (isinstance(tduration, timedelta) and (tduration < timedelta(0))))):
        ret = '-'
    else:
        ret = ''
    ret += strftime(tduration, format)
    return ret
def duration_isoformat(tduration, format=D_DEFAULT):
    '''
    Format duration strings.

    This method is just a wrapper around isodate.isostrf.strftime and uses
    P%P (D_DEFAULT) as default format.
    '''
    # TODO: implement better decision for negative Durations.
    #       should be done in Duration class in consistent way with timedelta.
    if (((isinstance(tduration, Duration)
          and (tduration.years < 0 or tduration.months < 0
               or tduration.tdelta < timedelta(0)))
         or (isinstance(tduration, timedelta)
             and (tduration < timedelta(0))))):
        ret = '-'
    else:
        ret = ''
    ret += strftime(tduration, format)
    return ret