Example #1
0
    def test_dec_dt_roundtrip():
        tzx = datetime.timezone(datetime.timedelta(days=-1, seconds=77400))
        dt_in = datetime.datetime(2020, 1, 16, 13, 37, 20, 12345, tzinfo=tzx)

        buf = encode_sched(dt_in)
        assert decode_sched(buf, 0, len(buf)) == dt_in
Example #2
0
def test_sched_zerovalue_dec():
    # Policy: somewhat arbitrary, but matches golang zero-value time, except for the Aware and UTC parts.
    zero_datetime = datetime.datetime(1, 1, 1)
    assert decode_sched(SBytes(""), 0, 0) == zero_datetime
Example #3
0
 def test_dec_dt_offset_sub():
     assert decode_sched(SBytes("e2 c8 1f 01 10 0d 25 14 a2 b9 60"),0,11) == \
         datetime.datetime(2020,1,16,13,37,20, 12345, tzinfo=datetime.timezone(datetime.timedelta(days=-1, seconds=77400)))
Example #4
0
def test_dec_dt_sub():
    assert decode_sched(SBytes("c2 c8 1f 01 10 0d 25 14 b9 60"), 0,
                        10) == datetime.datetime(2020, 1, 16, 13, 37, 20,
                                                 12345)
Example #5
0
def test_dec_dt_time():
    assert decode_sched(SBytes("40 0d 25 14"), 0,
                        4) == datetime.time(13, 37, 20)
Example #6
0
def test_dec_dt_date():
    assert decode_sched(SBytes("80 c8 1f 01 10"), 0,
                        5) == datetime.date(2020, 1, 16)
Example #7
0
def test_dec_dt_date_time():
    assert decode_sched(SBytes("c0 c8 1f 01 10 0d 25 14"), 0,
                        8) == datetime.datetime(2020, 1, 16, 13, 37, 20)