Ejemplo n.º 1
0
def test_struct_time_format_extreme_large():
    # extreme large epoch time
    value = SnowflakeDateTime(time.gmtime(14567890123567), nanosecond=0, scale=1)
    formatter = SnowflakeDateTimeFormat(
        'YYYY-MM-DD"T"HH24:MI:SS.FF', datetime_class=SnowflakeDateTime
    )
    assert formatter.format(value) == "463608-01-23T09:26:07.0"
def test_struct_time_format():
    # struct_time for general use
    value = time.strptime("30 Sep 01 11:20:30", "%d %b %y %H:%M:%S")
    formatter = SnowflakeDateTimeFormat('YYYY-MM-DD"T"HH24:MI:SS.FF')
    assert formatter.format(value) == '2001-09-30T11:20:30.0'

    # struct_time encapsulated in SnowflakeDateTime. Mainly used by SnowSQL
    value = SnowflakeDateTime(time.strptime("30 Sep 01 11:20:30",
                                            "%d %b %y %H:%M:%S"),
                              nanosecond=0,
                              scale=1)
    formatter = SnowflakeDateTimeFormat('YYYY-MM-DD"T"HH24:MI:SS.FF',
                                        datetime_class=SnowflakeDateTime)
    assert formatter.format(value) == '2001-09-30T11:20:30.0'

    # format without fraction of seconds
    formatter = SnowflakeDateTimeFormat('YYYY-MM-DD"T"HH24:MI:SS',
                                        datetime_class=SnowflakeDateTime)
    assert formatter.format(value) == '2001-09-30T11:20:30'