Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 3
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)
Exemplo n.º 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)
Exemplo n.º 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
Exemplo n.º 6
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