Skip to content

Commit 3ac9e09

Browse files
committed
Drop implementation for older Python releases
1 parent a4757b5 commit 3ac9e09

1 file changed

Lines changed: 3 additions & 18 deletions

File tree

src/timecode/timecode.py

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -885,32 +885,17 @@ def frame_number(self) -> int:
885885
"""
886886
return self.frames - 1
887887

888+
888889
@property
889890
def float(self) -> float:
890891
"""Return the seconds as float.
891892
892893
Returns:
893894
float: The seconds as float.
894895
"""
896+
import math
895897
time_value = float(self.frames) / float(self._int_framerate)
896-
# Add a very small epsilon - just enough to ensure we're above the truncation point
897-
# but not so much that we'd jump to the next frame
898-
epsilon = 1e-10 # This is much smaller than 1/framerate for any reasonable framerate
899-
return time_value + epsilon
900-
901-
if sys.version_info >= (3, 9):
902-
# Python 3.9+ supports math.nextafter, which we can use
903-
# to shift the float by the smallest possible amount
904-
@property
905-
def float(self) -> float:
906-
"""Return the seconds as float.
907-
908-
Returns:
909-
float: The seconds as float.
910-
"""
911-
import math
912-
time_value = float(self.frames) / float(self._int_framerate)
913-
return math.nextafter(time_value, math.inf)
898+
return math.nextafter(time_value, math.inf)
914899

915900

916901
class TimecodeError(Exception):

0 commit comments

Comments
 (0)