File tree Expand file tree Collapse file tree 1 file changed +9
-9
lines changed Expand file tree Collapse file tree 1 file changed +9
-9
lines changed Original file line number Diff line number Diff line change @@ -100,9 +100,11 @@ def validate_discord_token(token: str) -> bool:
100
100
else :
101
101
return True
102
102
103
+
103
104
def pluralize (count : int , singular : str ) -> str :
104
105
return singular if count == 1 else singular + "s"
105
106
107
+
106
108
def natural_time (
107
109
td : datetime .timedelta ,
108
110
/ ,
@@ -114,8 +116,13 @@ def natural_time(
114
116
then = now - td
115
117
future = then > now
116
118
117
- ago = "{delta} from now" if future else "{delta} ago"
118
119
seconds = round (td .total_seconds ())
120
+
121
+ if seconds < 60 and not future :
122
+ return "now"
123
+
124
+ ago = "{delta} from now" if future else "{delta} ago"
125
+
119
126
years , seconds = divmod (seconds , 60 * 60 * 24 * 365 )
120
127
months , seconds = divmod (seconds , 60 * 60 * 24 * 30 )
121
128
weeks , seconds = divmod (seconds , 60 * 60 * 24 * 7 )
@@ -142,14 +149,7 @@ def natural_time(
142
149
if ret :
143
150
ret += ", "
144
151
ret += f"{ hours } { pluralize (hours , 'hour' )} "
145
- if (
146
- minutes
147
- and not years
148
- and not months
149
- and not weeks
150
- and not days
151
- and not hours
152
- ):
152
+ if minutes and not years and not months and not weeks and not days and not hours :
153
153
if ret :
154
154
ret += ", "
155
155
ret += f"{ minutes } { pluralize (minutes , 'minute' )} "
You can’t perform that action at this time.
0 commit comments