MCPcopy Index your code
hub / github.com/dbcli/pgcli / duration_in_words

Function duration_in_words

pgcli/main.py:1992–2012  ·  view source on GitHub ↗
(duration_in_seconds: float)

Source from the content-addressed store, hash-verified

1990
1991
1992def duration_in_words(duration_in_seconds: float) -> str:
1993 if not duration_in_seconds:
1994 return "0 seconds"
1995 components = []
1996 hours, remainder = divmod(duration_in_seconds, 3600)
1997 if hours > 1:
1998 components.append(f"{int(hours)} hours")
1999 elif hours == 1:
2000 components.append("1 hour")
2001 minutes, seconds = divmod(remainder, 60)
2002 if minutes > 1:
2003 components.append(f"{int(minutes)} minutes")
2004 elif minutes == 1:
2005 components.append("1 minute")
2006 if seconds >= 2:
2007 components.append(f"{int(seconds)} seconds")
2008 elif seconds >= 1:
2009 components.append("1 second")
2010 elif seconds:
2011 components.append(f"{round(seconds, 3)} second")
2012 return " ".join(components)
2013
2014
2015if __name__ == "__main__":

Callers 2

test_duration_in_wordsFunction · 0.90
execute_commandMethod · 0.85

Calls

no outgoing calls

Tested by 1

test_duration_in_wordsFunction · 0.72