mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-29 21:11:16 +00:00
Rename SealedDate.__str__ to partial_isoformat
Django uses `str(date)` for backends other than PostgreSQL, so do not break "YYYY-MM-DD" formatting, just in case.
This commit is contained in:
parent
a9c605ea97
commit
46d80d56a5
2 changed files with 6 additions and 6 deletions
|
@ -14,14 +14,14 @@ class SealedDateTest(unittest.TestCase):
|
|||
def test_day_seal(self):
|
||||
sealed = sealed_date.SealedDate.from_datetime(self.dt)
|
||||
self.assertEqual(self.dt, sealed)
|
||||
self.assertEqual("2023-10-20", str(sealed))
|
||||
self.assertEqual("2023-10-20", sealed.partial_isoformat())
|
||||
|
||||
def test_month_seal(self):
|
||||
sealed = sealed_date.MonthSeal.from_datetime(self.dt)
|
||||
self.assertEqual(self.dt, sealed)
|
||||
self.assertEqual("2023-10", str(sealed))
|
||||
self.assertEqual("2023-10", sealed.partial_isoformat())
|
||||
|
||||
def test_year_seal(self):
|
||||
sealed = sealed_date.YearSeal.from_datetime(self.dt)
|
||||
self.assertEqual(self.dt, sealed)
|
||||
self.assertEqual("2023", str(sealed))
|
||||
self.assertEqual("2023", sealed.partial_isoformat())
|
||||
|
|
|
@ -12,7 +12,7 @@ class SealedDate(datetime): # TODO: migrate from DateTimeField to DateField
|
|||
def has_month(self) -> bool:
|
||||
return True
|
||||
|
||||
def __str__(self):
|
||||
def partial_isoformat(self) -> str:
|
||||
return self.strftime("%Y-%m-%d")
|
||||
|
||||
@classmethod
|
||||
|
@ -26,7 +26,7 @@ class MonthSeal(SealedDate):
|
|||
def has_day(self) -> bool:
|
||||
return False
|
||||
|
||||
def __str__(self):
|
||||
def partial_isoformat(self) -> str:
|
||||
return self.strftime("%Y-%m")
|
||||
|
||||
|
||||
|
@ -35,5 +35,5 @@ class YearSeal(SealedDate):
|
|||
def has_month(self) -> bool:
|
||||
return False
|
||||
|
||||
def __str__(self):
|
||||
def partial_isoformat(self) -> str:
|
||||
return self.strftime("%Y")
|
||||
|
|
Loading…
Reference in a new issue