def get_group_information(self, preview_adapter): """Rendered as hidden field per entry""" attr = self._query()['sort_on'] context = preview_adapter.context value = getattr(context, attr)() if isinstance(value, DateTime): return readable_date_text(context, value) else: return value
def test_none_if_value_is_invalid(self): self.assertEqual( None, readable_date_text(object, 'invalid date'))
def test_none_if_no_value_is_given(self): self.assertEqual( None, readable_date_text(object, None))
def test_if_date_is_older_than_yesterday_return_it_as_date(self): self.assertEqual( '17.10.2012', readable_date_text(object, datetime(2012, 10, 17, 20, 8)))
def test_if_date_is_yesterday_return_it_as_string(self): yesterday = (datetime.now() - timedelta(1)) self.assertEqual( 'gestern', readable_date_text(object, yesterday))
def test_if_date_is_today_return_it_as_string(self): self.assertEqual( 'heute', readable_date_text(object, datetime.now()))