diff --git a/python_files/pyhelpers.py b/python_files/pyhelpers.py index 45059786cf4faeedcfc067bf5e05d8cf8f820d46..86f19a7dafaa303f9dd2faa2aecbde08fca8504c 100644 --- a/python_files/pyhelpers.py +++ b/python_files/pyhelpers.py @@ -104,13 +104,19 @@ def absolutedate_to_datetime(orekit_absolutedate): or_date = or_comp.getDate() or_time = or_comp.getTime() seconds = or_time.getSecond() + seconds_int = int(math.floor(seconds)) + microseconds = int(1000000.0 * (seconds - math.floor(seconds))) + if seconds_int > 59: # This can take the value 60 during a leap second + seconds_int = 59 + microseconds = 999999 # Also modifying microseconds to ensure that the time flow stays monotonic + return datetime(or_date.getYear(), or_date.getMonth(), or_date.getDay(), or_time.getHour(), or_time.getMinute(), - int(math.floor(seconds)), - int(1000000.0 * (seconds - math.floor(seconds)))) + seconds_int, + microseconds) def datetime_to_absolutedate(dt_date):