Skip to content

Commit 870488c

Browse files
committed
refactor: extract function-level constants to module-level
- Ensures better adherence to PEP 8 naming conventions and improves code readability.
1 parent 6495753 commit 870488c

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

src/pendulum/formatting/difference_formatter.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,22 @@
88
if t.TYPE_CHECKING:
99
from pendulum import Duration
1010

11+
DAYS_THRESHOLD_FOR_HALF_WEEK = 3
12+
DAYS_THRESHOLD_FOR_HALF_MONTH = 15
13+
MONTHS_THRESHOLD_FOR_HALF_YEAR = 6
14+
15+
HOURS_IN_NEARLY_A_DAY = 22
16+
DAYS_IN_NEARLY_A_MONTH = 27
17+
MONTHS_IN_NEARLY_A_YEAR = 11
18+
19+
DAYS_OF_WEEK = 7
20+
SECONDS_OF_MINUTE = 60
21+
FEW_SECONDS_MAX = 10
22+
23+
KEY_FUTURE = ".future"
24+
KEY_PAST = ".past"
25+
KEY_AFTER = ".after"
26+
KEY_BEFORE = ".before"
1127

1228
class DifferenceFormatter:
1329
"""
@@ -32,22 +48,6 @@ def format(
3248
:param absolute: Whether it's an absolute difference or not
3349
:param locale: The locale to use
3450
"""
35-
DAYS_THRESHOLD_FOR_HALF_WEEK = 3
36-
DAYS_THRESHOLD_FOR_HALF_MONTH = 15
37-
MONTHS_THRESHOLD_FOR_HALF_YEAR = 6
38-
39-
HOURS_IN_NEARLY_A_DAY = 22
40-
DAYS_IN_NEARLY_A_MONTH = 27
41-
MONTHS_IN_NEARLY_A_YEAR = 11
42-
43-
DAYS_OF_WEEK = 7
44-
SECONDS_OF_MINUTE = 60
45-
FEW_SECONDS_MAX = 10
46-
47-
KEY_FUTURE = ".future"
48-
KEY_PAST = ".past"
49-
KEY_AFTER = ".after"
50-
KEY_BEFORE = ".before"
5151
locale = self._locale if locale is None else Locale.load(locale)
5252

5353
if diff.years > 0:

0 commit comments

Comments
 (0)