Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions arrow/arrow.py
Original file line number Diff line number Diff line change
Expand Up @@ -1682,6 +1682,30 @@ def isoweekday(self) -> int:

return self._datetime.isoweekday()

def is_weekday(self) -> bool:
"""Returns a boolean indicating whether the day is a weekday (Monday-Friday).

Usage::

>>> arrow.utcnow().is_weekday()
True

"""

return self.weekday() in range(0, 5)

def is_weekend(self) -> bool:
"""Returns a boolean indicating whether the day is a weekend (Saturday-Sunday).

Usage::

>>> arrow.utcnow().is_weekend()
False

"""

return self.weekday() in (5, 6)

def isocalendar(self) -> Tuple[int, int, int]:
"""Returns a 3-tuple, (ISO year, ISO week number, ISO weekday).

Expand Down
14 changes: 14 additions & 0 deletions tests/test_arrow.py
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,20 @@ def test_isoweekday(self):

assert result == self.arrow._datetime.isoweekday()

def test_is_weekday(self):
monday = arrow.Arrow(2023, 1, 2)
saturday = arrow.Arrow(2023, 1, 7)

assert monday.is_weekday() is True
assert saturday.is_weekday() is False

def test_is_weekend(self):
saturday = arrow.Arrow(2023, 1, 7)
monday = arrow.Arrow(2023, 1, 2)

assert saturday.is_weekend() is True
assert monday.is_weekend() is False

def test_isocalendar(self):
result = self.arrow.isocalendar()

Expand Down
Loading