Example #1
0
def http_date_from_timestamp(timestamp):
    """
    Turn a modifier or created tiddler ``timestamp``
    into a properly formatted HTTP date. If the timestamp
    is invalid use the current time as the timestamp.
    """
    try:
        timestamp_datetime = timestring_to_datetime(timestamp)
    except ValueError:
        timestamp_datetime = timestring_to_datetime(current_timestring())
    return timestamp_datetime.strftime('%a, %d %b %Y %H:%M:%S GMT')
Example #2
0
def http_date_from_timestamp(timestamp):
    """
    Turn a modifier or created tiddler ``timestamp``
    into a properly formatted HTTP date. If the timestamp
    is invalid use the current time as the timestamp.
    """
    try:
        timestamp_datetime = timestring_to_datetime(timestamp)
    except ValueError:
        timestamp_datetime = timestring_to_datetime(current_timestring())
    return timestamp_datetime.strftime('%a, %d %b %Y %H:%M:%S GMT')
def rfc3339(modified_string):
    """
    Translate a tiddler modified or created string into a RFC 3339 date string,
    e.g. 2013-07-11T16:54:01Z
    """
    datetime_object = timestring_to_datetime(modified_string)
    return datetime_object.isoformat('T') + 'Z'
Example #4
0
def test_timestring_to_datetime():
    """
    Confirm a timestring becomes the expected datetime object.
    """
    timestring = '20130711154400'
    date_object = timestring_to_datetime(timestring)

    assert date_object.year == 2013
    assert date_object.month == 7
    assert date_object.day == 11
    assert date_object.hour == 15
    assert date_object.minute == 44
    assert date_object.second == 00
Example #5
0
def test_timestring_to_datetime():
    """
    Confirm a timestring becomes the expected datetime object.
    """
    timestring = '20130711154400'
    date_object = timestring_to_datetime(timestring)

    assert date_object.year == 2013
    assert date_object.month == 7
    assert date_object.day == 11
    assert date_object.hour == 15
    assert date_object.minute == 44
    assert date_object.second == 00