Пример #1
0
 def format_value(self, value):
     """Format an EDTF date."""
     return format_edtf(value, format=self._format, locale=self.locale)
Пример #2
0
 def embargo_date(self):
     """Embargo date."""
     until = self.record_access_dict.get('embargo').get('until')
     if until:
         return format_edtf(until, format='long')
     return until
Пример #3
0
def test_format_edtf_format():
    """Test overriding the format."""
    assert format_edtf('2020-11', format='yMd', locale='en') == '11/1/2020'
    assert format_edtf('2020/2021', format='yM', locale='en') == \
        '1/2020 – 12/2021'
Пример #4
0
def test_format_edtf(edtfstr, locale, format, expected):
    assert format_edtf(edtfstr, format=format, locale=locale) == expected
Пример #5
0
def test_format_edtf_default():
    """Test the default time being used if not value provided."""
    today = datetime.utcnow().date()
    assert format_edtf(format='short', locale='en') == '{}/{}/{}'.format(
        today.month, today.day,
        str(today.year)[2:4])