Exemplo n.º 1
0
def unpickle_timezone_information(offset):
    """
    Unpickle timezone information
    @param offset: timezone utc offset
    """
    utc_tz = dateutils.utc_tz()
    utc_offset = utc_tz.utcoffset(None)
    if offset == utc_offset:
        return utc_tz
    local_tz = dateutils.local_tz()
    local_offset = local_tz.utcoffset(None)
    if offset == local_offset:
        return local_tz
    offset_hours = offset.days * 24
    offset_minutes = offset.seconds / 60
    return isodate.FixedOffset(offset_hours, offset_minutes)
Exemplo n.º 2
0
 def test_datetime_tz_python_obj_isodate(self):
     tz8 = isodate.FixedOffset(offset_hours=8)
     expected = datetime.datetime(2018, 2, 5, 8, 0, tzinfo=tz8)
     assert self.datetime_test == expected