How to use the isodate.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 jortel / gofer / test / functional / server.py View on Github external
def test_expired():
    # valid
    expiration = dt.utcnow() + timedelta(seconds=10)
    expiration = expiration.replace(tzinfo=isodate.UTC)
    expiration = isodate.strftime(expiration, isodate.DT_EXT_COMPLETE)
    agent = Agent(expiration=expiration)
    admin = agent.Admin()
    print admin.echo('FUTURE')
    # invalid
    agent = Agent(expiration='12345')
    admin = agent.Admin()
    print admin.echo('INVALID')
    # expired
    expiration = dt.utcnow() - timedelta(seconds=10)
    expiration = expiration.replace(tzinfo=isodate.UTC)
    expiration = isodate.strftime(expiration, isodate.DT_EXT_COMPLETE)
    agent = Agent(wait=0, expiration=expiration)
    admin = agent.Admin()
    print admin.echo('EXPIRED')
    sys.exit(0)
github pulp / pulpcore / common / pulp / common / dateutils.py View on Github external
def format_iso8601_datetime(dt):
    """
    Format a datetime instance as an iso8601 string.
    @type dt: datetime.datetime instance
    @param dt: datetime instance to format
    @rtype: str
    @return: iso8601 representation of the passed in datetime instance
    """
    return isodate.strftime(dt, isodate.DT_EXT_COMPLETE)
github pulp / pulpcore / common / pulp / common / dateutils.py View on Github external
def format_iso8601_date(d):
    """
    Fomate a date instance as an iso8601 string.
    @type d: datetime.date instance
    @param d: date instance to format
    @rtype: str
    @return: iso8601 representation of the passed in date instance
    """
    return isodate.strftime(d, isodate.DATE_EXT_COMPLETE)
github pulp / pulp / common / pulp / common / dateutils.py View on Github external
def format_iso8601_datetime(dt):
    """
    Format a datetime instance as an iso8601 string.
    @type dt: datetime.datetime instance
    @param dt: datetime instance to format
    @rtype: str
    @return: iso8601 representation of the passed in datetime instance
    """
    return isodate.strftime(dt, isodate.DT_EXT_COMPLETE)
github pulp / pulpcore / common / pulp / common / dateutils.py View on Github external
def format_iso8601_datetime(dt):
    """
    Format a datetime instance as an iso8601 string.
    @type dt: datetime.datetime instance
    @param dt: datetime instance to format
    @rtype: str
    @return: iso8601 representation of the passed in datetime instance
    """
    return isodate.strftime(dt, isodate.DT_EXT_COMPLETE)
github pulp / pulp / common / pulp / common / dateutils.py View on Github external
Format a time interval as an iso8601 string.
    @type interval: datetime.timedelta instance
    @param interval: length of the interval
    @type start_time: datetime.datetime instance or None
    @param start_time: (optional) start time of the interval
    @type recurrences: int
    @param recurrences: (optional) number of times intercal recures
    @rtype: str
    @return: iso8601 representation of the passed in time interval
    """
    parts = []
    if recurrences is not None:
        parts.append('R%d' % recurrences)
    if start_time is not None:
        parts.append(format_iso8601_datetime(start_time))
    parts.append(isodate.strftime(interval, isodate.D_DEFAULT))
    return '/'.join(parts)
github pulp / pulpcore / common / pulp / common / dateutils.py View on Github external
def format_iso8601_date(d):
    """
    Fomate a date instance as an iso8601 string.
    @type d: datetime.date instance
    @param d: date instance to format
    @rtype: str
    @return: iso8601 representation of the passed in date instance
    """
    return isodate.strftime(d, isodate.DATE_EXT_COMPLETE)
github pulp / pulpcore / common / pulp / common / dateutils.py View on Github external
Format a time interval as an iso8601 string.
    @type interval: datetime.timedelta instance
    @param interval: length of the interval
    @type start_time: datetime.datetime instance or None
    @param start_time: (optional) start time of the interval
    @type recurrences: int
    @param recurrences: (optional) number of times intercal recures
    @rtype: str
    @return: iso8601 representation of the passed in time interval
    """
    parts = []
    if recurrences is not None:
        parts.append('R%d' % recurrences)
    if start_time is not None:
        parts.append(format_iso8601_datetime(start_time))
    parts.append(isodate.strftime(interval, isodate.D_DEFAULT))
    return '/'.join(parts)
github pulp / pulpcore / common / pulp / common / dateutils.py View on Github external
Format a time interval as an iso8601 string.
    @type interval: datetime.timedelta instance
    @param interval: length of the interval
    @type start_time: datetime.datetime instance or None
    @param start_time: (optional) start time of the interval
    @type recurrences: int
    @param recurrences: (optional) number of times intercal recures
    @rtype: str
    @return: iso8601 representation of the passed in time interval
    """
    parts = []
    if recurrences is not None:
        parts.append('R%d' % recurrences)
    if start_time is not None:
        parts.append(format_iso8601_datetime(start_time))
    parts.append(isodate.strftime(interval, isodate.D_DEFAULT))
    return '/'.join(parts)