@@ -203,7 +203,7 @@ class HEREImageType(enum.Enum):
203
203
EmergencyAlert = collections .namedtuple ("EmergencyAlert" , ["message" , "control_data" , "categories" , "location_format" , "locations" ])
204
204
AudioService = collections .namedtuple ("AudioService" , ["program" , "access" , "type" , "codec_mode" , "blend_control" ,
205
205
"digital_audio_gain" , "common_delay" , "latency" ])
206
- HEREImage = collections .namedtuple ("HEREImage" , ["image_type" , "seq" , "n1" , "n2" , "timestamp " , "latitude1" , "longitude1" ,
206
+ HEREImage = collections .namedtuple ("HEREImage" , ["image_type" , "seq" , "n1" , "n2" , "time_utc " , "latitude1" , "longitude1" ,
207
207
"latitude2" , "longitude2" , "name" , "data" ])
208
208
209
209
@@ -521,7 +521,7 @@ class _HEREImage(ctypes.Structure):
521
521
("seq" , ctypes .c_int ),
522
522
("n1" , ctypes .c_int ),
523
523
("n2" , ctypes .c_int ),
524
- ("timestamp " , ctypes .c_uint ),
524
+ ("time_utc " , ctypes .POINTER ( _TimeStruct ) ),
525
525
("latitude1" , ctypes .c_float ),
526
526
("longitude1" , ctypes .c_float ),
527
527
("latitude2" , ctypes .c_float ),
@@ -591,6 +591,18 @@ def _decode(string):
591
591
return string
592
592
return string .decode ()
593
593
594
+ @staticmethod
595
+ def _timestruct_to_datetime (ts ):
596
+ return datetime .datetime (
597
+ ts .contents .tm_year + 1900 ,
598
+ ts .contents .tm_mon + 1 ,
599
+ ts .contents .tm_mday ,
600
+ ts .contents .tm_hour ,
601
+ ts .contents .tm_min ,
602
+ ts .contents .tm_sec ,
603
+ tzinfo = datetime .timezone .utc
604
+ )
605
+
594
606
def _callback_wrapper (self , c_evt ):
595
607
c_evt = c_evt .contents
596
608
evt = None
@@ -683,16 +695,7 @@ def _callback_wrapper(self, c_evt):
683
695
lot = c_evt .u .lot
684
696
service = self .services [lot .service .contents .number ]
685
697
component = self .components [(lot .service .contents .number , lot .component .contents .id )]
686
- expiry_struct = lot .expiry_utc .contents
687
- expiry_time = datetime .datetime (
688
- expiry_struct .tm_year + 1900 ,
689
- expiry_struct .tm_mon + 1 ,
690
- expiry_struct .tm_mday ,
691
- expiry_struct .tm_hour ,
692
- expiry_struct .tm_min ,
693
- expiry_struct .tm_sec ,
694
- tzinfo = datetime .timezone .utc
695
- )
698
+ expiry_time = self ._timestruct_to_datetime (lot .expiry_utc )
696
699
evt = LOT (lot .port , lot .lot , MIMEType (lot .mime ), self ._decode (lot .name ), lot .data [:lot .size ], expiry_time , service , component )
697
700
elif evt_type == EventType .SIS :
698
701
sis = c_evt .u .sis
@@ -774,12 +777,13 @@ def _callback_wrapper(self, c_evt):
774
777
)
775
778
elif evt_type == EventType .HERE_IMAGE :
776
779
here_image = c_evt .u .here_image
780
+ time_utc = self ._timestruct_to_datetime (here_image .time_utc )
777
781
evt = HEREImage (
778
782
HEREImageType (here_image .image_type ),
779
783
here_image .seq ,
780
784
here_image .n1 ,
781
785
here_image .n2 ,
782
- datetime . datetime . fromtimestamp ( here_image . timestamp , tz = datetime . timezone . utc ) ,
786
+ time_utc ,
783
787
here_image .latitude1 ,
784
788
here_image .longitude1 ,
785
789
here_image .latitude2 ,
0 commit comments