week of year
This commit is contained in:
parent
6e8c2da118
commit
d73f93c27f
@ -70,6 +70,15 @@ class FixedDate:
|
||||
return 1
|
||||
return ((self.day_of_month-1) // 7) + 1
|
||||
|
||||
@property
|
||||
def weekday(self) -> int:
|
||||
"""Ordinal of the day in week. Value 1 for year day.
|
||||
|
||||
Returns:
|
||||
int: 1 for Sunday, 2 for Monday, 7 for Saturday
|
||||
"""
|
||||
return ((self.day_of_month-1) % 7) + 1
|
||||
|
||||
@property
|
||||
def week_of_year(self) -> int:
|
||||
"""The ordinal of the week in year. Value 53 for year day.
|
||||
@ -79,7 +88,6 @@ class FixedDate:
|
||||
"""
|
||||
return ((self._day_of_year-1) // 7) + 1
|
||||
|
||||
# TODO: weekday
|
||||
# TODO: year quarter
|
||||
# TODO: datetime instance
|
||||
# TODO: plus and minus operations
|
||||
|
@ -10,6 +10,7 @@ class TestBasicDatetimeInit(unittest.TestCase):
|
||||
self.assertEqual(fixed_date.day_of_month, 1)
|
||||
self.assertEqual(fixed_date.day_of_year, 1)
|
||||
self.assertEqual(fixed_date.week_of_month, 1)
|
||||
self.assertEqual(fixed_date.weekday, 1)
|
||||
self.assertEqual(fixed_date.week_of_year, 1)
|
||||
|
||||
def test_datetime_init_february_last(self):
|
||||
@ -19,6 +20,7 @@ class TestBasicDatetimeInit(unittest.TestCase):
|
||||
self.assertEqual(fixed_date.day_of_month, 28)
|
||||
self.assertEqual(fixed_date.day_of_year, 56)
|
||||
self.assertEqual(fixed_date.week_of_month, 4)
|
||||
self.assertEqual(fixed_date.weekday, 7)
|
||||
self.assertEqual(fixed_date.week_of_year, 8)
|
||||
|
||||
def test_datetime_init_sol_month(self):
|
||||
|
Loading…
x
Reference in New Issue
Block a user