def test_date(self): """Expects date format.""" value_test = datetime.fromordinal(733900) value_expected = format_date(value_test, locale=self.locale) value_returned = datetimeformat(self.context, value_test, format='date') eq_(pq(value_returned)('time').text(), value_expected)
def test_time(self): """Expects time format.""" value_test = datetime.fromordinal(733900) value_localize = self.timezone.localize(value_test) value_expected = format_time(value_localize, locale=self.locale, tzinfo=self.timezone) value_returned = datetimeformat(self.context, value_test, format='time') eq_(pq(value_returned)('time').text(), value_expected)
def test_today(self): """Expects shortdatetime, format: Today at {time}.""" date_today = datetime.today() date_localize = self.timezone.localize(date_today) value_returned = unicode(datetimeformat(self.context, date_today)) value_expected = 'Today at {0!s}'.format(format_time(date_localize, format='short', locale=self.locale, tzinfo=self.timezone)) eq_(pq(value_returned)('time').text(), value_expected)
def test_today(self): """Expects shortdatetime, format: Today at {time}.""" date_today = datetime.today() date_localize = self.timezone.localize(date_today) value_returned = unicode(datetimeformat(self.context, date_today)) value_expected = 'Today at %s' % format_time(date_localize, format='short', locale=self.locale, tzinfo=self.timezone) eq_(pq(value_returned)('time').text(), value_expected)
def _get_datetime_result(self, locale, timezone, format='short', return_format='shortdatetime'): value = datetime.fromordinal(733900) value = self.timezone.localize(value) value_test = value.astimezone(self.timezone) value_localize = value_test.astimezone(timezone) value_expected = format_datetime(value_localize, format=format, locale=locale, tzinfo=timezone) value_returned = datetimeformat(self.context, value_test, format=return_format) eq_(pq(value_returned)('time').text(), value_expected)