File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed
Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change 44
55from pendulum .locales .locale import Locale
66
7+
78DAYS_THRESHOLD_FOR_HALF_WEEK = 3
89DAYS_THRESHOLD_FOR_HALF_MONTH = 15
910MONTHS_THRESHOLD_FOR_HALF_YEAR = 6
@@ -56,15 +57,19 @@ def format(
5657
5758 if diff .months > MONTHS_THRESHOLD_FOR_HALF_YEAR :
5859 count += 1
59- elif (diff .months == MONTHS_IN_NEARLY_A_YEAR
60- and (diff .weeks * DAYS_OF_WEEK + diff .remaining_days ) > DAYS_THRESHOLD_FOR_HALF_MONTH ):
60+ elif (diff .months == MONTHS_IN_NEARLY_A_YEAR ) and (
61+ (diff .weeks * DAYS_OF_WEEK + diff .remaining_days )
62+ > DAYS_THRESHOLD_FOR_HALF_MONTH
63+ ):
6164 unit = "year"
6265 count = 1
6366 elif diff .months > 0 :
6467 unit = "month"
6568 count = diff .months
6669
67- if (diff .weeks * DAYS_OF_WEEK + diff .remaining_days ) >= DAYS_IN_NEARLY_A_MONTH :
70+ if (
71+ diff .weeks * DAYS_OF_WEEK + diff .remaining_days
72+ ) >= DAYS_IN_NEARLY_A_MONTH :
6873 count += 1
6974 elif diff .weeks > 0 :
7075 unit = "week"
@@ -106,7 +111,7 @@ def format(
106111 key += self .KEY_AFTER
107112 else :
108113 key += self .KEY_BEFORE
109-
114+
110115 return t .cast (str , locale .get (key ).format (time ))
111116 else :
112117 unit = "second"
You can’t perform that action at this time.
0 commit comments