Beispiel #1
0
def test_format_time_time_with_format():
    i18n.set_locale(i18n.Locale('en', 'US', timezone='America/Los_Angeles'))

    t = datetime.time(15, 30)
    assert i18n.format_time(t, format="hh 'o''clock' a, zzzz") == "03 o'clock PM, Pacific Standard Time"

    t = datetime.time(15, 30, tzinfo=pytz.timezone('Europe/Paris'))
    assert i18n.format_time(t, format="hh 'o''clock' a, zzzz") == "03 o'clock PM, Pacific Standard Time"
Beispiel #2
0
    def test_format_time_time_with_format(self):
        i18n.set_locale(i18n.Locale('en', 'US', timezone='Pacific/Pitcairn'))

        t = datetime.time(15, 30)
        self.assertEqual(i18n.format_time(t, format="hh 'o''clock' a, zzzz"), "03 o'clock PM, Pitcairn Time")

        t = datetime.time(15, 30, tzinfo=pytz.timezone('Africa/Niamey'))
        self.assertEqual(i18n.format_time(t, format="hh 'o''clock' a, zzzz"), "03 o'clock PM, Pitcairn Time")
Beispiel #3
0
def test_format_time_datetime_with_format():
    i18n.set_locale(i18n.Locale('en', 'US', timezone='America/Los_Angeles'))

    d = datetime.datetime(2007, 4, 1, 15, 30)
    assert i18n.format_time(d, format="hh 'o''clock' a, zzzz") == "03 o'clock PM, Pacific Daylight Time"

    d = datetime.datetime(2007, 4, 1, 15, 30, tzinfo=pytz.timezone('Europe/Paris'))
    assert i18n.format_time(d, format="hh 'o''clock' a, zzzz") == "08 o'clock AM, Pacific Daylight Time"
Beispiel #4
0
    def test_format_time_datetime_with_format(self):
        i18n.set_locale(i18n.Locale('en', 'US', timezone='Pacific/Pitcairn'))

        d = datetime.datetime(2007, 4, 1, 15, 30)
        self.assertEqual(i18n.format_time(d, format="hh 'o''clock' a, zzzz"), u"03 o'clock PM, Pitcairn Time")

        tz = pytz.timezone('Africa/Niamey')
        d = tz.localize(datetime.datetime(2007, 4, 1, 15, 30))
        self.assertEqual(i18n.format_time(d, format="hh 'o''clock' a, zzzz"), u"06 o'clock AM, Pitcairn Time")
Beispiel #5
0
def test_format_time_time_en():
    i18n.set_locale(i18n.Locale('en', 'US', timezone='Pacific/Pitcairn'))

    t = datetime.time(15, 30)

    assert i18n.format_time(t, format='full') == '3:30:00 PM Pitcairn Time'
    assert i18n.format_time(t, format='long') == '3:30:00 PM -0800'
    assert i18n.format_time(t, format='medium') == '3:30:00 PM'
    assert i18n.format_time(t) == '3:30:00 PM'
    assert i18n.format_time(t, format='short') == '3:30 PM'
Beispiel #6
0
    def test_format_time_time_en(self):
        i18n.set_locale(i18n.Locale('en', 'US', timezone='Pacific/Pitcairn'))

        t = datetime.time(15, 30)

        self.assertEqual(i18n.format_time(t, format='full'), '3:30:00 PM Pitcairn Time')
        self.assertEqual(i18n.format_time(t, format='long'), '3:30:00 PM -0800')
        self.assertEqual(i18n.format_time(t, format='medium'), '3:30:00 PM')
        self.assertEqual(i18n.format_time(t), '3:30:00 PM')
        self.assertEqual(i18n.format_time(t, format='short'), '3:30 PM')
Beispiel #7
0
    def test_format_time_time_fr4(self):
        i18n.set_locale(i18n.Locale('fr', 'FR', timezone='Africa/Niamey'))

        t = datetime.time(15, 30, tzinfo=pytz.timezone('Pacific/Pitcairn'))

        self.assertEqual(i18n.format_time(t, format='full'), u'15:30:00 heure normale d’Afrique de l’Ouest')
        self.assertEqual(i18n.format_time(t, format='long'), '15:30:00 +0100')
        self.assertEqual(i18n.format_time(t, format='medium'), '15:30:00')
        self.assertEqual(i18n.format_time(t), '15:30:00')
        self.assertEqual(i18n.format_time(t, format='short'), '15:30')
Beispiel #8
0
def test_format_time_time_fr3():
    i18n.set_locale(i18n.Locale('fr', 'FR'))

    t = datetime.time(15, 30, tzinfo=pytz.timezone('America/Los_Angeles'))

    assert i18n.format_time(t, format='full') == '15:30:00 Monde (GMT)'
    assert i18n.format_time(t, format='long') == '15:30:00 +0000'
    assert i18n.format_time(t, format='medium') == '15:30:00'
    assert i18n.format_time(t) == '15:30:00'
    assert i18n.format_time(t, format='short') == '15:30'
Beispiel #9
0
    def test_format_time_time_with_format(self):
        i18n.set_locale(i18n.Locale('en', 'US', timezone='Pacific/Pitcairn'))

        t = datetime.time(15, 30)
        self.assertEqual(i18n.format_time(t, format="hh 'o''clock' a, zzzz"),
                         "03 o'clock PM, Pitcairn Time")

        t = datetime.time(15, 30, tzinfo=pytz.timezone('Africa/Niamey'))
        self.assertEqual(i18n.format_time(t, format="hh 'o''clock' a, zzzz"),
                         "03 o'clock PM, Pitcairn Time")
Beispiel #10
0
def test_format_time_time_fr4():
    i18n.set_locale(i18n.Locale('fr', 'FR', timezone='Europe/Paris'))

    t = datetime.time(15, 30, tzinfo=pytz.timezone('America/Los_Angeles'))

    assert i18n.format_time(t, format='full') == '15:30:00 HEC'
    assert i18n.format_time(t, format='long') == '15:30:00 HNEC'
    assert i18n.format_time(t, format='medium') == '15:30:00'
    assert i18n.format_time(t) == '15:30:00'
    assert i18n.format_time(t, format='short') == '15:30'
Beispiel #11
0
def test_format_time_time_fr1():
    i18n.set_locale(i18n.Locale('fr', 'FR'))

    t = datetime.time(15, 30)

    assert i18n.format_time(t, format='full') == '15:30:00 Monde (GMT)'
    assert i18n.format_time(t, format='long') == '15:30:00 +0000'
    assert i18n.format_time(t, format='medium') == '15:30:00'
    assert i18n.format_time(t) == '15:30:00'
    assert i18n.format_time(t, format='short') == '15:30'
Beispiel #12
0
def test_format_time_datetime_fr3():
    i18n.set_locale(i18n.Locale('fr', 'FR', timezone='Europe/Paris', default_timezone=pytz.UTC))

    d = datetime.datetime(2007, 4, 1, 15, 30)

    assert i18n.format_time(d, format='full') == '17:30:00 HEC'
    assert i18n.format_time(d, format='long') == '17:30:00 HAEC'
    assert i18n.format_time(d, format='medium') == '17:30:00'
    assert i18n.format_time(d) == '17:30:00'
    assert i18n.format_time(d, format='short') == '17:30'
Beispiel #13
0
def test_format_time_datetime_fr4():
    i18n.set_locale(i18n.Locale('fr', 'FR'))

    d = datetime.datetime(2007, 4, 1, 15, 30, tzinfo=pytz.timezone('America/Los_Angeles'))

    assert i18n.format_time(d, format='full') == '23:30:00 Monde (GMT)'
    assert i18n.format_time(d, format='long') == '23:30:00 +0000'
    assert i18n.format_time(d, format='medium') == '23:30:00'
    assert i18n.format_time(d) == '23:30:00'
    assert i18n.format_time(d, format='short') == '23:30'
Beispiel #14
0
def test_format_time_datetime_fr5():
    i18n.set_locale(i18n.Locale('fr', 'FR', timezone='Europe/Paris'))

    d = datetime.datetime(2007, 4, 1, 15, 30, tzinfo=pytz.timezone('America/Los_Angeles'))

    assert i18n.format_time(d, format='full') == '01:30:00 HEC'
    assert i18n.format_time(d, format='long') == '01:30:00 HAEC'
    assert i18n.format_time(d, format='medium') == '01:30:00'
    assert i18n.format_time(d) == '01:30:00'
    assert i18n.format_time(d, format='short') == '01:30'
Beispiel #15
0
    def test_format_time_datetime_fr3(self):
        i18n.set_locale(i18n.Locale('fr', 'FR', timezone='Africa/Niamey', default_timezone=pytz.UTC))

        d = datetime.datetime(2007, 4, 1, 15, 30)

        self.assertEqual(i18n.format_time(d, format='full'), u'16:30:00 heure normale d’Afrique de l’Ouest')
        self.assertEqual(i18n.format_time(d, format='long'), '16:30:00 +0100')
        self.assertEqual(i18n.format_time(d, format='medium'), '16:30:00')
        self.assertEqual(i18n.format_time(d), '16:30:00')
        self.assertEqual(i18n.format_time(d, format='short'), '16:30')
Beispiel #16
0
def test_format_time_datetime_fr1():
    i18n.set_locale(i18n.Locale('fr', 'FR'))

    d = datetime.datetime(2007, 4, 1, 15, 30)

    assert i18n.format_time(d, format='full') == '15:30:00 Monde (GMT)'
    assert i18n.format_time(d, format='long') == '15:30:00 +0000'
    assert i18n.format_time(d, format='medium') == '15:30:00'
    assert i18n.format_time(d) == '15:30:00'
    assert i18n.format_time(d, format='short') == '15:30'
Beispiel #17
0
def test_format_time_time_en():
    i18n.set_locale(i18n.Locale('en', 'US', timezone='America/Los_Angeles'))

    t = datetime.time(15, 30)

    assert i18n.format_time(t, format='full') == '3:30:00 PM PT'
    assert i18n.format_time(t, format='long') == '3:30:00 PM PST'
    assert i18n.format_time(t, format='medium') == '3:30:00 PM'
    assert i18n.format_time(t) == '3:30:00 PM'
    assert i18n.format_time(t, format='short') == '3:30 PM'
Beispiel #18
0
    def test_format_time_datetime_fr1(self):
        i18n.set_locale(i18n.Locale('fr', 'FR'))

        d = datetime.datetime(2007, 4, 1, 15, 30)

        self.assertEqual(i18n.format_time(d, format='full'), '15:30:00 UTC+00:00')
        self.assertEqual(i18n.format_time(d, format='long'), '15:30:00 +0000')
        self.assertEqual(i18n.format_time(d, format='medium'), '15:30:00')
        self.assertEqual(i18n.format_time(d), '15:30:00')
        self.assertEqual(i18n.format_time(d, format='short'), '15:30')
Beispiel #19
0
def test_format_time_time_fr2():
    i18n.set_locale(i18n.Locale('fr', 'FR', timezone='Europe/Paris'))

    t = datetime.time(15, 30)

    assert i18n.format_time(t, format='full') == '15:30:00 HEC'
    assert i18n.format_time(t, format='long') == '15:30:00 HNEC'
    assert i18n.format_time(t, format='medium') == '15:30:00'
    assert i18n.format_time(t) == '15:30:00'
    assert i18n.format_time(t, format='short') == '15:30'
Beispiel #20
0
    def test_format_time_time_fr3(self):
        i18n.set_locale(i18n.Locale('fr', 'FR'))

        t = datetime.time(15, 30, tzinfo=pytz.timezone('Pacific/Pitcairn'))

        self.assertEqual(i18n.format_time(t, format='full'), '15:30:00 UTC+00:00')
        self.assertEqual(i18n.format_time(t, format='long'), '15:30:00 +0000')
        self.assertEqual(i18n.format_time(t, format='medium'), '15:30:00')
        self.assertEqual(i18n.format_time(t), '15:30:00')
        self.assertEqual(i18n.format_time(t, format='short'), '15:30')
Beispiel #21
0
    def test_format_time_time_fr1(self):
        i18n.set_locale(i18n.Locale('fr', 'FR'))

        t = datetime.time(15, 30)

        self.assertEqual(i18n.format_time(t, format='full'), '15:30:00 UTC+00:00')
        self.assertEqual(i18n.format_time(t, format='long'), '15:30:00 +0000')
        self.assertEqual(i18n.format_time(t, format='medium'), '15:30:00')
        self.assertEqual(i18n.format_time(t), '15:30:00')
        self.assertEqual(i18n.format_time(t, format='short'), '15:30')
Beispiel #22
0
    def test_format_time_datetime_fr1(self):
        i18n.set_locale(i18n.Locale('fr', 'FR'))

        d = datetime.datetime(2007, 4, 1, 15, 30)

        self.assertEqual(i18n.format_time(d, format='full'),
                         '15:30:00 UTC+00:00')
        self.assertEqual(i18n.format_time(d, format='long'), '15:30:00 +0000')
        self.assertEqual(i18n.format_time(d, format='medium'), '15:30:00')
        self.assertEqual(i18n.format_time(d), '15:30:00')
        self.assertEqual(i18n.format_time(d, format='short'), '15:30')
def test_format_time():
    t = datetime.time(15, 30)

    set_locale(Locale('en', 'US'))
    assert i18n.format_time(t) == '3:30:00 PM'

    set_locale(Locale('de', 'DE'))
    assert i18n.format_time(t, format='short') == '15:30'

    set_locale(Locale('en'))
    assert i18n.format_time(t, "hh 'o''clock' a") == "03 o'clock PM"
Beispiel #24
0
    def test_format_time_datetime_fr5(self):
        i18n.set_locale(i18n.Locale('fr', 'FR', timezone='Africa/Niamey'))

        tz = pytz.timezone('Pacific/Pitcairn')
        d = tz.localize(datetime.datetime(2007, 4, 1, 15, 30))

        self.assertEqual(i18n.format_time(d, format='full'), u'00:30:00 heure normale d’Afrique de l’Ouest')
        self.assertEqual(i18n.format_time(d, format='long'), '00:30:00 +0100')
        self.assertEqual(i18n.format_time(d, format='medium'), '00:30:00')
        self.assertEqual(i18n.format_time(d), '00:30:00')
        self.assertEqual(i18n.format_time(d, format='short'), '00:30')
Beispiel #25
0
    def test_format_time_datetime_fr4(self):
        i18n.set_locale(i18n.Locale('fr', 'FR'))

        tz = pytz.timezone('Pacific/Pitcairn')
        d = tz.localize(datetime.datetime(2007, 4, 1, 15, 30))

        self.assertEqual(i18n.format_time(d, format='full'), '23:30:00 UTC+00:00')
        self.assertEqual(i18n.format_time(d, format='long'), '23:30:00 +0000')
        self.assertEqual(i18n.format_time(d, format='medium'), '23:30:00')
        self.assertEqual(i18n.format_time(d), '23:30:00')
        self.assertEqual(i18n.format_time(d, format='short'), '23:30')
Beispiel #26
0
    def test_format_time_time_fr3(self):
        i18n.set_locale(i18n.Locale('fr', 'FR'))

        t = datetime.time(15, 30, tzinfo=pytz.timezone('Pacific/Pitcairn'))

        self.assertEqual(i18n.format_time(t, format='full'),
                         '15:30:00 UTC+00:00')
        self.assertEqual(i18n.format_time(t, format='long'), '15:30:00 +0000')
        self.assertEqual(i18n.format_time(t, format='medium'), '15:30:00')
        self.assertEqual(i18n.format_time(t), '15:30:00')
        self.assertEqual(i18n.format_time(t, format='short'), '15:30')
Beispiel #27
0
    def test_format_time_datetime_fr2(self):
        i18n.set_locale(i18n.Locale('fr', 'FR', timezone='Africa/Niamey'))

        d = datetime.datetime(2007, 4, 1, 15, 30)

        self.assertEqual(i18n.format_time(d, format='full'),
                         u'15:30:00 heure normale d’Afrique de l’Ouest')
        self.assertEqual(i18n.format_time(d, format='long'), '15:30:00 +0100')
        self.assertEqual(i18n.format_time(d, format='medium'), '15:30:00')
        self.assertEqual(i18n.format_time(d), '15:30:00')
        self.assertEqual(i18n.format_time(d, format='short'), '15:30')
Beispiel #28
0
    def test_format_time_datetime_with_format(self):
        i18n.set_locale(i18n.Locale('en', 'US', timezone='Pacific/Pitcairn'))

        d = datetime.datetime(2007, 4, 1, 15, 30)
        self.assertEqual(i18n.format_time(d, format="hh 'o''clock' a, zzzz"),
                         u"03 o'clock PM, Pitcairn Time")

        tz = pytz.timezone('Africa/Niamey')
        d = tz.localize(datetime.datetime(2007, 4, 1, 15, 30))
        self.assertEqual(i18n.format_time(d, format="hh 'o''clock' a, zzzz"),
                         u"06 o'clock AM, Pitcairn Time")
Beispiel #29
0
def test_format_time_time_fr3():
    i18n.set_locale(i18n.Locale('fr', 'FR'))

    t = datetime.time(15, 30, tzinfo=pytz.timezone('Pacific/Pitcairn'))

    assert i18n.format_time(
        t, format='full') == u'15:30:00 Temps universel coordonné'
    assert i18n.format_time(t, format='long') == '15:30:00 TU'
    assert i18n.format_time(t, format='medium') == '15:30:00'
    assert i18n.format_time(t) == '15:30:00'
    assert i18n.format_time(t, format='short') == '15:30'
Beispiel #30
0
    def test_format_time_time_fr4(self):
        i18n.set_locale(i18n.Locale('fr', 'FR', timezone='Africa/Niamey'))

        t = datetime.time(15, 30, tzinfo=pytz.timezone('Pacific/Pitcairn'))

        self.assertEqual(i18n.format_time(t, format='full'),
                         u'15:30:00 heure normale d’Afrique de l’Ouest')
        self.assertEqual(i18n.format_time(t, format='long'), '15:30:00 +0100')
        self.assertEqual(i18n.format_time(t, format='medium'), '15:30:00')
        self.assertEqual(i18n.format_time(t), '15:30:00')
        self.assertEqual(i18n.format_time(t, format='short'), '15:30')
Beispiel #31
0
def test_format_time_time_fr2():
    i18n.set_locale(i18n.Locale('fr', 'FR', timezone='Africa/Niamey'))

    t = datetime.time(15, 30)

    assert i18n.format_time(
        t, format='full') == u'15:30:00 heure normale d’Afrique de l’Ouest'
    assert i18n.format_time(t, format='long') == '15:30:00 +0100'
    assert i18n.format_time(t, format='medium') == '15:30:00'
    assert i18n.format_time(t) == '15:30:00'
    assert i18n.format_time(t, format='short') == '15:30'
Beispiel #32
0
def test_format_time_datetime_fr1():
    i18n.set_locale(i18n.Locale('fr', 'FR'))

    d = datetime.datetime(2007, 4, 1, 15, 30)

    assert i18n.format_time(
        d, format='full') == u'15:30:00 Temps universel coordonné'
    assert i18n.format_time(d, format='long') == '15:30:00 TU'
    assert i18n.format_time(d, format='medium') == '15:30:00'
    assert i18n.format_time(d) == '15:30:00'
    assert i18n.format_time(d, format='short') == '15:30'
Beispiel #33
0
    def test_format_time_time_fr1(self):
        i18n.set_locale(i18n.Locale('fr', 'FR'))

        t = datetime.time(15, 30)

        self.assertEqual(i18n.format_time(t, format='full'),
                         '15:30:00 UTC+00:00')
        self.assertEqual(i18n.format_time(t, format='long'), '15:30:00 +0000')
        self.assertEqual(i18n.format_time(t, format='medium'), '15:30:00')
        self.assertEqual(i18n.format_time(t), '15:30:00')
        self.assertEqual(i18n.format_time(t, format='short'), '15:30')
Beispiel #34
0
    def test_format_time_time_en(self):
        i18n.set_locale(i18n.Locale('en', 'US', timezone='Pacific/Pitcairn'))

        t = datetime.time(15, 30)

        self.assertEqual(i18n.format_time(t, format='full'),
                         '3:30:00 PM Pitcairn Time')
        self.assertEqual(i18n.format_time(t, format='long'),
                         '3:30:00 PM -0800')
        self.assertEqual(i18n.format_time(t, format='medium'), '3:30:00 PM')
        self.assertEqual(i18n.format_time(t), '3:30:00 PM')
        self.assertEqual(i18n.format_time(t, format='short'), '3:30 PM')
Beispiel #35
0
    def test_format_time_datetime_fr4(self):
        i18n.set_locale(i18n.Locale('fr', 'FR'))

        tz = pytz.timezone('Pacific/Pitcairn')
        d = tz.localize(datetime.datetime(2007, 4, 1, 15, 30))

        self.assertEqual(i18n.format_time(d, format='full'),
                         '23:30:00 UTC+00:00')
        self.assertEqual(i18n.format_time(d, format='long'), '23:30:00 +0000')
        self.assertEqual(i18n.format_time(d, format='medium'), '23:30:00')
        self.assertEqual(i18n.format_time(d), '23:30:00')
        self.assertEqual(i18n.format_time(d, format='short'), '23:30')
Beispiel #36
0
    def test_format_time_datetime_fr5(self):
        i18n.set_locale(i18n.Locale('fr', 'FR', timezone='Africa/Niamey'))

        tz = pytz.timezone('Pacific/Pitcairn')
        d = tz.localize(datetime.datetime(2007, 4, 1, 15, 30))

        self.assertEqual(i18n.format_time(d, format='full'),
                         u'00:30:00 heure normale d’Afrique de l’Ouest')
        self.assertEqual(i18n.format_time(d, format='long'), '00:30:00 +0100')
        self.assertEqual(i18n.format_time(d, format='medium'), '00:30:00')
        self.assertEqual(i18n.format_time(d), '00:30:00')
        self.assertEqual(i18n.format_time(d, format='short'), '00:30')
Beispiel #37
0
def test_format_time_datetime_fr4():
    i18n.set_locale(i18n.Locale('fr', 'FR'))

    tz = pytz.timezone('Pacific/Pitcairn')
    d = tz.localize(datetime.datetime(2007, 4, 1, 15, 30))

    assert i18n.format_time(
        d, format='full') == u'23:30:00 Temps universel coordonné'
    assert i18n.format_time(d, format='long') == '23:30:00 TU'
    assert i18n.format_time(d, format='medium') == '23:30:00'
    assert i18n.format_time(d) == '23:30:00'
    assert i18n.format_time(d, format='short') == '23:30'
Beispiel #38
0
def test_format_time_datetime_fr3():
    i18n.set_locale(
        i18n.Locale('fr',
                    'FR',
                    timezone='Africa/Niamey',
                    default_timezone=pytz.UTC))

    d = datetime.datetime(2007, 4, 1, 15, 30)

    assert i18n.format_time(
        d, format='full') == u'16:30:00 heure normale d’Afrique de l’Ouest'
    assert i18n.format_time(d, format='long') == '16:30:00 +0100'
    assert i18n.format_time(d, format='medium') == '16:30:00'
    assert i18n.format_time(d) == '16:30:00'
    assert i18n.format_time(d, format='short') == '16:30'