Skip to content

Commit

Permalink
refactor: extract function-level constants to module-level
Browse files Browse the repository at this point in the history
- Ensures better adherence to PEP 8 naming conventions and improves code readability.
  • Loading branch information
Minku-Koo committed Dec 18, 2024
1 parent 6495753 commit 870488c
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions src/pendulum/formatting/difference_formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,22 @@
if t.TYPE_CHECKING:
from pendulum import Duration

DAYS_THRESHOLD_FOR_HALF_WEEK = 3
DAYS_THRESHOLD_FOR_HALF_MONTH = 15
MONTHS_THRESHOLD_FOR_HALF_YEAR = 6

HOURS_IN_NEARLY_A_DAY = 22
DAYS_IN_NEARLY_A_MONTH = 27
MONTHS_IN_NEARLY_A_YEAR = 11

DAYS_OF_WEEK = 7
SECONDS_OF_MINUTE = 60
FEW_SECONDS_MAX = 10

KEY_FUTURE = ".future"
KEY_PAST = ".past"
KEY_AFTER = ".after"
KEY_BEFORE = ".before"

class DifferenceFormatter:
"""
Expand All @@ -32,22 +48,6 @@ def format(
:param absolute: Whether it's an absolute difference or not
:param locale: The locale to use
"""
DAYS_THRESHOLD_FOR_HALF_WEEK = 3
DAYS_THRESHOLD_FOR_HALF_MONTH = 15
MONTHS_THRESHOLD_FOR_HALF_YEAR = 6

HOURS_IN_NEARLY_A_DAY = 22
DAYS_IN_NEARLY_A_MONTH = 27
MONTHS_IN_NEARLY_A_YEAR = 11

DAYS_OF_WEEK = 7
SECONDS_OF_MINUTE = 60
FEW_SECONDS_MAX = 10

KEY_FUTURE = ".future"
KEY_PAST = ".past"
KEY_AFTER = ".after"
KEY_BEFORE = ".before"
locale = self._locale if locale is None else Locale.load(locale)

if diff.years > 0:
Expand Down

0 comments on commit 870488c

Please sign in to comment.