Example #1
0
    def _roundtrip_test(self, time_string):
        expected_datetime = np.datetime64(time_string)

        timestamp = types.TimeStamp(expected_datetime)
        data_file = io.BytesIO(timestamp.bytes)

        read_datetime = types.TimeStamp.read(data_file)

        self.assertEqual(expected_datetime, read_datetime)
Example #2
0
def test_timestamp_round_trip(time_string):
    expected_datetime = np.datetime64(time_string)

    timestamp = types.TimeStamp(expected_datetime)
    data_file = io.BytesIO(timestamp.bytes)

    read_datetime = types.TimeStamp.read(data_file)

    assert expected_datetime == read_datetime
Example #3
0
    def test_timestamp_from_date(self):
        """Test timestamp from built in date value"""

        input_datetime = date(2019, 11, 8)
        expected_datetime = np.datetime64('2019-11-08T00:00:00')

        timestamp = types.TimeStamp(input_datetime)
        data_file = io.BytesIO(timestamp.bytes)

        read_datetime = types.TimeStamp.read(data_file)

        self.assertEqual(expected_datetime, read_datetime)
Example #4
0
def test_timestamp_from_datetime():
    """Test timestamp from built in datetime value"""

    input_datetime = datetime(2019, 11, 8, 18, 47, 0)
    expected_datetime = np.datetime64('2019-11-08T18:47:00')

    timestamp = types.TimeStamp(input_datetime)
    data_file = io.BytesIO(timestamp.bytes)

    read_datetime = types.TimeStamp.read(data_file)

    assert expected_datetime == read_datetime