You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@avro.apache.org by GitBox <gi...@apache.org> on 2022/07/02 21:32:28 UTC

[GitHub] [avro] kojiromike commented on a diff in pull request #1634: AVRO-3476: Implement Local Timestamp Logical Types

kojiromike commented on code in PR #1634:
URL: https://github.com/apache/avro/pull/1634#discussion_r912402445


##########
lang/py/avro/io.py:
##########
@@ -362,25 +362,52 @@ def read_time_micros_from_long(self) -> datetime.time:
         microseconds = self.read_long()
         return self._build_time_object(microseconds, 1)
 
-    def read_timestamp_millis_from_long(self) -> datetime.datetime:
+    def _read_timestamp_millis_from_long(self, tz:bool) -> datetime.datetime:
         """
         long is decoded as python datetime object which represents
         the number of milliseconds from the unix epoch, 1 January 1970.
         """
         timestamp_millis = self.read_long()
         timedelta = datetime.timedelta(microseconds=timestamp_millis * 1000)
-        unix_epoch_datetime = datetime.datetime(1970, 1, 1, 0, 0, 0, 0, tzinfo=avro.timezones.utc)
+        unix_epoch_datetime = datetime.datetime(1970, 1, 1, 0, 0, 0, 0, tzinfo=avro.timezones.utc if tz else None)
         return unix_epoch_datetime + timedelta
 
-    def read_timestamp_micros_from_long(self) -> datetime.datetime:
+    def _read_timestamp_micros_from_long(self,tz:bool) -> datetime.datetime:
         """
         long is decoded as python datetime object which represents
         the number of microseconds from the unix epoch, 1 January 1970.
         """
         timestamp_micros = self.read_long()
         timedelta = datetime.timedelta(microseconds=timestamp_micros)
-        unix_epoch_datetime = datetime.datetime(1970, 1, 1, 0, 0, 0, 0, tzinfo=avro.timezones.utc)
+        unix_epoch_datetime = datetime.datetime(1970, 1, 1, 0, 0, 0, 0, tzinfo=avro.timezones.utc if tz else None)
         return unix_epoch_datetime + timedelta
+    def read_local_timestamp_micros_from_long(self) -> datetime.datetime:

Review Comment:
   Are you sure about this? I am not great at reading Java, but I understand that a `LocalDateTime` is essentially a DateTime without a timezone, which is what I'm doing here: setting `tz=None` if the type is local.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@avro.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org