Merge pull request #27868 from akhilnarang/fix-format_timedelta
fix: don't call `.total_seconds()` if the object isn't of type `datetime.timedelta`
This commit is contained in:
commit
a04aba0408
1 changed files with 7 additions and 4 deletions
|
|
@ -2442,10 +2442,13 @@ class UnicodeWithAttrs(str):
|
|||
self.metadata = text.metadata
|
||||
|
||||
|
||||
def format_timedelta(o: datetime.timedelta) -> str:
|
||||
# mariadb allows a wide diff range - https://mariadb.com/kb/en/time/
|
||||
# but frappe doesnt - i think via babel : only allows 0..23 range for hour
|
||||
total_seconds = o.total_seconds()
|
||||
def format_timedelta(o: datetime.timedelta | str) -> str:
|
||||
# MariaDB allows a wide range - https://mariadb.com/kb/en/time/
|
||||
# but Frappe doesn't - I think via babel : only allows 0..23 range for hour
|
||||
if isinstance(o, datetime.timedelta):
|
||||
total_seconds = o.total_seconds()
|
||||
else:
|
||||
total_seconds = cint(o)
|
||||
hours, remainder = divmod(total_seconds, 3600)
|
||||
minutes, seconds = divmod(remainder, 60)
|
||||
rounded_seconds = round(seconds, 6)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue