Example #1
0
    def test_cython_local_zoned_timestamp_coder(self):
        import datetime
        import pytz
        timezone = pytz.timezone("Asia/Shanghai")
        data = [
            timezone.localize(
                datetime.datetime(2019, 9, 10, 18, 30, 20, 123000))
        ]
        python_field_coders = [
            coder_impl.LocalZonedTimestampCoderImpl(3, timezone)
            for _ in range(len(data))
        ]
        cython_field_coders = [
            fast_coder_impl.LocalZonedTimestampCoderImpl(3, timezone)
            for _ in range(len(data))
        ]
        self.check_cython_coder(python_field_coders, cython_field_coders,
                                [data])

        data = [
            timezone.localize(
                datetime.datetime(2019, 9, 10, 18, 30, 20, 123456))
        ]
        python_field_coders = [
            coder_impl.LocalZonedTimestampCoderImpl(6, timezone)
            for _ in range(len(data))
        ]
        cython_field_coders = [
            fast_coder_impl.LocalZonedTimestampCoderImpl(6, timezone)
            for _ in range(len(data))
        ]
        self.check_cython_coder(python_field_coders, cython_field_coders,
                                [data])
Example #2
0
 def get_impl(self):
     return coder_impl.LocalZonedTimestampCoderImpl(self.precision,
                                                    self.timezone)