From ed54bf69ba0d764ac8a485107207b409101df67c Mon Sep 17 00:00:00 2001 From: kami Date: Sat, 1 Feb 2025 11:07:36 +0000 Subject: [PATCH] Upload files to "modules" --- modules/utility.cpython-312.pyc | Bin 0 -> 1191 bytes modules/utility.py | 34 ++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 modules/utility.cpython-312.pyc create mode 100644 modules/utility.py diff --git a/modules/utility.cpython-312.pyc b/modules/utility.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..e4bf5797ea71b513c033b9727bb26112d4c176ca GIT binary patch literal 1191 zcmZ8g&ube;6rTMhtz;{z6+4#Wl1^~#SRpZq>MF&AT;j%uCTWNr3Spt$XxH*$?XEI2 z>sDd~a>zlrm%T+04109RpVG?~U&PjjLQg&f4ECv~yjdy2?gM@E-uKOW^XBd7&s;8x zz*>*@YnqJEzdZPC5GQu}B`oidfefLJULr#@1w%5$P1%s&$}gp+P*RTh#;0+bnpM{^ zXq+M@^N3Rwk^%$ZE(7}xv61GZ4@19=7~heY5668F2fhYtTezSK|5L@ba4uIg z#0$AnTRf*qhIB!d+tN7|u603G+On@0%JwQkMD>;T$VmAzV0vF(N4`8#IH&p&U?x$d zk;1vGF9MDwia1g@H|`67xkM3$iZbLxI01orX&<~&zE#a)u!pX*V-kjk)5ey=T&&|Q z&(@vW#MBM_Ro%pt5zDEqBpK#XZ3%x<#+w9OF!X@U4!arf zgS&uV5@QK26sHVp$99cUitr~9r-!Y_3a>z8nfD*32HnRBZ;a9u?BoN&_`hGOE7}Wc z5~^(yow(YnNw=BX&^CUxSal0;xNeL%4ZX4PT;QllB?HeF)t>}RjREZZanIGcA$KLT{n**MA>OsdxIBOTon6%;#$N z!qUM?l&?f;rJwmCxVtyoFU$lpy_->fK2qoZIUk(Dg;7b4Wj=>k*{r)dizRq|$xQx0 vh~CL=ptyZ!~ryePSEqFbX literal 0 HcmV?d00001 diff --git a/modules/utility.py b/modules/utility.py new file mode 100644 index 0000000..bec6ebd --- /dev/null +++ b/modules/utility.py @@ -0,0 +1,34 @@ +import time + +def format_uptime(seconds: float) -> str: + """ + Convert seconds into a human-readable string: + e.g. 32 minutes, 8 days, 8 months, etc. + """ + # Convert float seconds to an integer + seconds = int(seconds) + + # We'll break it down + minutes, seconds = divmod(seconds, 60) + hours, minutes = divmod(minutes, 60) + days, hours = divmod(hours, 24) + # For months and years, let's approximate 30 days per month, + # 365 days per year, etc. (just a rough approach) + + months, days = divmod(days, 30) + years, months = divmod(months, 12) + + # Build a short string, only listing the largest units + # If you want more detail, you can keep going + if years > 0: + return f"{years} year(s), {months} month(s)" + elif months > 0: + return f"{months} month(s), {days} day(s)" + elif days > 0: + return f"{days} day(s), {hours} hour(s)" + elif hours > 0: + return f"{hours} hour(s), {minutes} minute(s)" + elif minutes > 0: + return f"{minutes} minute(s)" + else: + return f"{seconds} second(s)" \ No newline at end of file