File tree 1 file changed +11
-3
lines changed
1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -109,15 +109,23 @@ def to_json(report: Report) -> Dict:
109
109
110
110
@staticmethod
111
111
def _extract_timestamp (ts ):
112
+ # Unix timestamp format (in milliseconds)
113
+ if isinstance (ts , int ):
114
+ return datetime .fromtimestamp (ts / 1000 )
115
+
116
+ # datetime object
117
+ if isinstance (ts , datetime ):
118
+ return ts
119
+
112
120
if isinstance (ts , str ):
113
121
try :
122
+ # ISO 8601 date format
114
123
return datetime .strptime (ts , "%Y-%m-%dT%H:%M:%S.%f" )
115
124
except ValueError :
125
+ # Unix timestamp format (in milliseconds)
116
126
return datetime .fromtimestamp (int (ts ) / 1000 )
117
- if isinstance (ts , datetime ):
118
- return ts
119
127
120
- raise ValueError ('timestamp must be a datetime.datetime or a string ' )
128
+ raise ValueError ('Invalid timestamp format ' )
121
129
122
130
@staticmethod
123
131
def create_empty_report ():
You can’t perform that action at this time.
0 commit comments