How to use the isodate.isostrf.strftime function in isodate

To help you get started, we’ve selected a few isodate examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mvantellingen / python-zeep / src / zeep / xsd / types / builtins.py View on Github external
# Bit of a hack, since datetime is a subclass of date we can't just
        # test it with an isinstance(). And actually, we should not really
        # care about the type, as long as it has the required attributes
        if not all(hasattr(value, attr) for attr in ("hour", "minute", "second")):
            value = datetime.datetime.combine(
                value,
                datetime.time(
                    getattr(value, "hour", 0),
                    getattr(value, "minute", 0),
                    getattr(value, "second", 0),
                ),
            )

        if getattr(value, "microsecond", 0):
            return isodate.isostrf.strftime(value, "%Y-%m-%dT%H:%M:%S.%f%Z")
        return isodate.isostrf.strftime(value, "%Y-%m-%dT%H:%M:%S%Z")
github sci-wms / sci-wms / wms / templatetags / wms.py View on Github external
def triple_period_format_z(ds):
    ws = []
    for w in ds:
        ws.append('/'.join([
            w[0].strftime('%Y-%m-%dT%H:%M:%S'),
            w[1].strftime('%Y-%m-%dT%H:%M:%S'),
            strftime(w[2], D_DEFAULT)
        ]))
    return ','.join(ws)
github gweis / isodate / src / isodate / isoduration.py View on Github external
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
github istSOS / istsos2 / lib__old / isodate / __init__.py View on Github external
from isodate.isostrf import DATE_EXT_WEEK_COMPLETE, DATE_MONTH, DATE_YEAR
from isodate.isostrf import TIME_BAS_COMPLETE, TIME_BAS_MINUTE
from isodate.isostrf import TIME_EXT_COMPLETE, TIME_EXT_MINUTE
from isodate.isostrf import TIME_HOUR
from isodate.isostrf import TZ_BAS, TZ_EXT, TZ_HOUR
from isodate.isostrf import DT_BAS_COMPLETE, DT_EXT_COMPLETE
from isodate.isostrf import DT_BAS_ORD_COMPLETE, DT_EXT_ORD_COMPLETE
from isodate.isostrf import DT_BAS_WEEK_COMPLETE, DT_EXT_WEEK_COMPLETE
from isodate.isostrf import D_DEFAULT, D_WEEK, D_ALT_EXT, D_ALT_BAS
from isodate.isostrf import D_ALT_BAS_ORD, D_ALT_EXT_ORD

__all__ = (parse_date, date_isoformat, parse_time, time_isoformat,
           parse_datetime, datetime_isoformat, parse_duration,
           duration_isoformat, ISO8601Error, parse_tzinfo,
           tz_isoformat, UTC, FixedOffset, LOCAL, Duration,
           strftime, DATE_BAS_COMPLETE, DATE_BAS_ORD_COMPLETE,
           DATE_BAS_WEEK, DATE_BAS_WEEK_COMPLETE, DATE_CENTURY,
           DATE_EXT_COMPLETE, DATE_EXT_ORD_COMPLETE, DATE_EXT_WEEK,
           DATE_EXT_WEEK_COMPLETE, DATE_MONTH, DATE_YEAR,
           TIME_BAS_COMPLETE, TIME_BAS_MINUTE, TIME_EXT_COMPLETE,
           TIME_EXT_MINUTE, TIME_HOUR, TZ_BAS, TZ_EXT, TZ_HOUR,
           DT_BAS_COMPLETE, DT_EXT_COMPLETE, DT_BAS_ORD_COMPLETE,
           DT_EXT_ORD_COMPLETE, DT_BAS_WEEK_COMPLETE,
           DT_EXT_WEEK_COMPLETE, D_DEFAULT, D_WEEK, D_ALT_EXT,
           D_ALT_BAS, D_ALT_BAS_ORD, D_ALT_EXT_ORD)
github rfletcher / plex-mlb / bundle / Contents / Libraries / isodate / isodatetime.py View on Github external
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)
github mvantellingen / python-zeep / src / zeep / xsd / types / builtins.py View on Github external
def xmlvalue(self, value):
        if isinstance(value, six.string_types):
            return value

        if value.microsecond:
            return isodate.isostrf.strftime(value, "%H:%M:%S.%f%Z")
        return isodate.isostrf.strftime(value, "%H:%M:%S%Z")
github istSOS / istsos2 / lib__old / isodate / isodates.py View on Github external
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)
github mercadopago / sdk-python / lib / mercadopago / lib / isodate / isoduration.py View on Github external
'''
    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
github mvantellingen / python-zeep / src / zeep / xsd / types / builtins.py View on Github external
def xmlvalue(self, value):
        if isinstance(value, six.string_types):
            return value

        if value.microsecond:
            return isodate.isostrf.strftime(value, "%H:%M:%S.%f%Z")
        return isodate.isostrf.strftime(value, "%H:%M:%S%Z")
github istSOS / istsos2 / lib__old / isodate / isodatetime.py View on Github external
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)