2023-01-09 22:07:03 +01:00
|
|
|
class FourDigitYearConverter:
|
|
|
|
regex = "[0-9]{4}"
|
|
|
|
|
|
|
|
def to_python(self, value):
|
|
|
|
return int(value)
|
|
|
|
|
|
|
|
def to_url(self, value):
|
|
|
|
return str(value).zfill(4)
|
|
|
|
|
|
|
|
|
|
|
|
class TwoDigitMonthConverter:
|
|
|
|
regex = "[0-9]{2}"
|
|
|
|
|
|
|
|
def to_python(self, value):
|
|
|
|
return int(value)
|
|
|
|
|
|
|
|
def to_url(self, value):
|
|
|
|
return str(value).zfill(2)
|
|
|
|
|
|
|
|
|
|
|
|
class BooleanStringConverter:
|
2024-07-12 09:34:16 +02:00
|
|
|
"""Converter whose regex match either True or False."""
|
2023-01-09 22:07:03 +01:00
|
|
|
|
|
|
|
regex = r"(True)|(False)"
|
|
|
|
|
|
|
|
def to_python(self, value):
|
|
|
|
return str(value) == "True"
|
|
|
|
|
|
|
|
def to_url(self, value):
|
|
|
|
return str(value)
|