Exemplo n.º 1
0
 def test_non_iso8601_utc_en(self):
     current_app.config['BABEL_DEFAULT_LOCALE'] = 'en_US'
     current_app.config['BABEL_DEFAULT_TIMEZONE'] = 'UTC'
     self.assertEqual(reformat_date('2020'), '2020')
     self.assertEqual(reformat_date('2020-10'), '2020-10')
     self.assertEqual(reformat_date('2020-05-05'), '2020-05-05')
     self.assertEqual(reformat_date('01/02/2021'), '01/02/2021')
     self.assertEqual(reformat_date('September 2020'), 'September 2020')
     self.assertEqual(reformat_date('September 20, 2020'),
                      'September 20, 2020')
     self.assertEqual(reformat_date('September 20, 2020', convert_tz=True),
                      'September 20, 2020')
     self.assertEqual(
         reformat_date('September 20, 2020', convert_tz=True, show_tz=True),
         'September 20, 2020')
Exemplo n.º 2
0
 def test_iso8601_est_en(self):
     current_app.config['BABEL_DEFAULT_LOCALE'] = 'en_US'
     current_app.config['BABEL_DEFAULT_TIMEZONE'] = 'EST'
     self.assertEqual(
         reformat_date('2020-09-17T07:11:41+00:00', convert_tz=True),
         '9/17/20, 2:11 AM')
     self.assertEqual(
         reformat_date('2020-09-17T07:11:41+00:00', convert_tz=False),
         '9/17/20, 7:11 AM')
     self.assertEqual(
         reformat_date('2020-09-17T07:11:41+00:00',
                       convert_tz=True,
                       show_tz=True), '9/17/20, 2:11 AM (EST)')
     self.assertEqual(
         reformat_date('2020-11-07T12:30:19Z', convert_tz=True),
         '11/7/20, 7:30 AM')
     self.assertEqual(
         reformat_date('2020-11-07T12:30:19Z', convert_tz=False),
         '11/7/20, 12:30 PM')
     self.assertEqual(
         reformat_date('2020-11-07T12:30:19Z',
                       convert_tz=True,
                       show_tz=True), '11/7/20, 7:30 AM (EST)')
     self.assertEqual(
         reformat_date('2019-07-22T20:42+00:00', convert_tz=True),
         '7/22/19, 3:42 PM')
     self.assertEqual(
         reformat_date('2019-07-22T20:42+00:00', convert_tz=False),
         '7/22/19, 8:42 PM')
     self.assertEqual(
         reformat_date('2019-07-22T20:42+00:00',
                       convert_tz=True,
                       show_tz=True), '7/22/19, 3:42 PM (EST)')
     self.assertEqual(
         reformat_date('2020-11-07T12:30:19-0500', convert_tz=True),
         '11/7/20, 12:30 PM')
     self.assertEqual(
         reformat_date('2020-11-07T12:30:19-0500', convert_tz=False),
         '11/7/20, 12:30 PM')
     self.assertEqual(
         reformat_date('2020-11-07T12:30:19-0500',
                       convert_tz=True,
                       show_tz=True), '11/7/20, 12:30 PM (EST)')
Exemplo n.º 3
0
 def test_iso8601_utc_fr(self):
     current_app.config['BABEL_DEFAULT_LOCALE'] = 'fr_FR'
     current_app.config['BABEL_DEFAULT_TIMEZONE'] = 'UTC'
     self.assertEqual(
         reformat_date('2020-09-17T07:11:41+00:00', convert_tz=True),
         '17/09/2020 07:11')
     self.assertEqual(
         reformat_date('2020-09-17T07:11:41+00:00', convert_tz=False),
         '17/09/2020 07:11')
     self.assertEqual(
         reformat_date('2020-09-17T07:11:41+00:00',
                       convert_tz=True,
                       show_tz=True), '17/09/2020 07:11 (UTC)')
     self.assertEqual(
         reformat_date('2020-11-07T12:30:19Z', convert_tz=True),
         '07/11/2020 12:30')
     self.assertEqual(
         reformat_date('2020-11-07T12:30:19Z', convert_tz=False),
         '07/11/2020 12:30')
     self.assertEqual(
         reformat_date('2020-11-07T12:30:19Z',
                       convert_tz=True,
                       show_tz=True), '07/11/2020 12:30 (UTC)')
     self.assertEqual(
         reformat_date('2019-07-22T20:42+00:00', convert_tz=True),
         '22/07/2019 20:42')
     self.assertEqual(
         reformat_date('2019-07-22T20:42+00:00', convert_tz=False),
         '22/07/2019 20:42')
     self.assertEqual(
         reformat_date('2019-07-22T20:42+00:00',
                       convert_tz=True,
                       show_tz=True), '22/07/2019 20:42 (UTC)')
     self.assertEqual(
         reformat_date('2020-11-07T12:30:19-0500', convert_tz=True),
         '07/11/2020 17:30')
     self.assertEqual(
         reformat_date('2020-11-07T12:30:19-0500', convert_tz=False),
         '07/11/2020 12:30')
     self.assertEqual(
         reformat_date('2020-11-07T12:30:19-0500',
                       convert_tz=True,
                       show_tz=True), '07/11/2020 17:30 (UTC)')
Exemplo n.º 4
0
 def test_non_iso8601_utc_fr(self):
     current_app.config['BABEL_DEFAULT_LOCALE'] = 'fr_FR'
     current_app.config['BABEL_DEFAULT_TIMEZONE'] = 'UTC'
     self.assertEqual(reformat_date('September 2020'), 'September 2020')
     self.assertEqual(reformat_date('September 20, 2020'),
                      'September 20, 2020')