@@ -375,37 +375,19 @@ def main():
375
375
if result .result_set .rows and result .result_set .rows [0 ]['earliest_run' ]:
376
376
earliest_run = result .result_set .rows [0 ]['earliest_run' ]
377
377
378
- # Convert timestamp to datetime
379
- if earliest_run > 1000000000000000 : # Microseconds
380
- timestamp_seconds = earliest_run / 1000000
381
- branch_creation_date = datetime .datetime .fromtimestamp (timestamp_seconds ).date ()
382
- print (f"Converted from microseconds: { branch_creation_date } " )
383
- else : # Seconds or milliseconds
384
- if earliest_run > MICROSECONDS_THRESHOLD : # Microseconds
385
- timestamp_seconds = earliest_run / 1000000
386
- branch_creation_date = datetime .datetime .fromtimestamp (timestamp_seconds ).date ()
387
- print (f"Converted from microseconds: { branch_creation_date } " )
388
- else : # Seconds or milliseconds
389
- if earliest_run > MILLISECONDS_THRESHOLD : # Milliseconds
390
- timestamp_seconds = earliest_run / 1000
391
- branch_creation_date = datetime .datetime .fromtimestamp (timestamp_seconds ).date ()
392
- print (f"Converted from milliseconds: { branch_creation_date } " )
393
- else : # Seconds
394
- branch_creation_date = datetime .datetime .fromtimestamp (earliest_run ).date ()
395
378
# Convert timestamp to datetime with error handling
396
379
try :
397
380
if earliest_run > 1000000000000000 : # Microseconds
398
381
timestamp_seconds = earliest_run / 1000000
399
382
branch_creation_date = datetime .datetime .fromtimestamp (timestamp_seconds ).date ()
400
383
print (f"Converted from microseconds: { branch_creation_date } " )
401
- else : # Seconds or milliseconds
402
- if earliest_run > 1000000000000 : # Milliseconds
403
- timestamp_seconds = earliest_run / 1000
404
- branch_creation_date = datetime .datetime .fromtimestamp (timestamp_seconds ).date ()
405
- print (f"Converted from milliseconds: { branch_creation_date } " )
406
- else : # Seconds
407
- branch_creation_date = datetime .datetime .fromtimestamp (earliest_run ).date ()
408
- print (f"Converted from seconds: { branch_creation_date } " )
384
+ elif earliest_run > 1000000000000 : # Milliseconds
385
+ timestamp_seconds = earliest_run / 1000
386
+ branch_creation_date = datetime .datetime .fromtimestamp (timestamp_seconds ).date ()
387
+ print (f"Converted from milliseconds: { branch_creation_date } " )
388
+ else : # Seconds
389
+ branch_creation_date = datetime .datetime .fromtimestamp (earliest_run ).date ()
390
+ print (f"Converted from seconds: { branch_creation_date } " )
409
391
except (OSError , OverflowError , ValueError ) as e :
410
392
print (f"Error converting timestamp { earliest_run } to datetime: { e } " )
411
393
branch_creation_date = None
0 commit comments