Exemplo n.º 1
0
    def date(self, date=None, format='medium'):
        """Return a date formatted according to the given pattern.

        >>> from datetime import date
        >>> fmt = Format('en_US')
        >>> fmt.date(date(2007, 4, 1))
        u'Apr 1, 2007'
        """
        return format_date(date, format, locale=self.locale)
Exemplo n.º 2
0
def test_format_date():
    d = date(2007, 4, 1)
    assert dates.format_date(d, locale="en_US") == u"Apr 1, 2007"
    assert dates.format_date(d, format="full", locale="de_DE") == u"Sonntag, 1. April 2007"
    assert dates.format_date(d, "EEE, MMM d, ''yy", locale="en") == u"Sun, Apr 1, '07"
Exemplo n.º 3
0
 def test_with_day_of_year_in_pattern_and_datetime_param(self):
     # format_date should work on datetimes just as well (see #282)
     d = datetime(2007, 4, 1)
     self.assertEqual("14", dates.format_date(d, "w", locale="en_US"))