def test_format_datetime(self):
        value = datetime.datetime(2009, 11, 10, 16, 36, 5)

        self.assertEqual(
            i18n.format_datetime(value, format='short'),
            u'11/10/09, 4:36 PM'
        )
        self.assertEqual(
            i18n.format_datetime(value, format='medium'),
            u'Nov 10, 2009, 4:36:05 PM'
        )
        self.assertEqual(
            i18n.format_datetime(value, format='long'),
            u'November 10, 2009 at 4:36:05 PM +0000'
        )

        # self.assertEqual(i18n.format_datetime(value, format='full'),
        # u'Tuesday, November 10, 2009 4:36:05 PM World (GMT) Time')

        self.assertEqual(
            i18n.format_datetime(value, format='full'),
            u'Tuesday, November 10, 2009 at 4:36:05 PM GMT+00:00'
        )

        i18n.get_i18n().set_timezone('America/Chicago')
        self.assertEqual(
            i18n.format_datetime(value, format='short'),
            u'11/10/09, 10:36 AM'
        )
예제 #2
0
    def test_format_datetime(self):
        value = datetime.datetime(2009, 11, 10, 16, 36, 5)

        self.assertEqual(
            i18n.format_datetime(value, format="short"), "11/10/09, 4:36 PM"
        )
        self.assertEqual(
            i18n.format_datetime(value, format="medium"), "Nov 10, 2009, 4:36:05 PM"
        )
        self.assertEqual(
            i18n.format_datetime(value, format="long"),
            "November 10, 2009 at 4:36:05 PM +0000",
        )

        # self.assertEqual(i18n.format_datetime(value, format='full'),
        # u'Tuesday, November 10, 2009 4:36:05 PM World (GMT) Time')

        self.assertEqual(
            i18n.format_datetime(value, format="full"),
            "Tuesday, November 10, 2009 at 4:36:05 PM GMT+00:00",
        )

        i18n.get_i18n().set_timezone("America/Chicago")
        self.assertEqual(
            i18n.format_datetime(value, format="short"), "11/10/09, 10:36 AM"
        )
    def test_format_datetime_pt_BR(self):
        i18n.get_i18n().set_locale('pt_BR')
        value = datetime.datetime(2009, 11, 10, 16, 36, 5)

        self.assertEqual(
            i18n.format_datetime(value, format='short'),
            u'10/11/09 16:36'
        )
        self.assertEqual(
            i18n.format_datetime(value, format='medium'),
            u'10 de nov de 2009 16:36:05'
        )
        # self.assertEqual(i18n.format_datetime(value, format='long'),
        # u'10 de novembro de 2009 16:36:05 +0000')
        self.assertEqual(
            i18n.format_datetime(value, format='long'),
            u'10 de novembro de 2009 16:36:05 +0000'
        )
        # self.assertEqual(i18n.format_datetime(value, format='full'),
        # u'terça-feira, 10 de novembro de 2009
        # 16h36min05s Horário Mundo (GMT)')
        self.assertEqual(
            i18n.format_datetime(value, format='full'),
            u'ter\xe7a-feira, 10 de novembro de 2009 16:36:05 GMT+00:00'
        )
예제 #4
0
    def test_format_datetime_pt_BR(self):
        i18n.get_i18n().set_locale('pt_BR')
        value = datetime.datetime(2009, 11, 10, 16, 36, 05)

        self.assertEqual(i18n.format_datetime(value, format='short'),
                         u'10/11/09 16:36')
        self.assertEqual(i18n.format_datetime(value, format='medium'),
                         u'10/11/2009 16:36:05')
        #self.assertEqual(i18n.format_datetime(value, format='long'), u'10 de novembro de 2009 16:36:05 +0000')
        self.assertEqual(i18n.format_datetime(value, format='long'),
                         u'10 de novembro de 2009 16h36min05s +0000')
        #self.assertEqual(i18n.format_datetime(value, format='full'), u'terça-feira, 10 de novembro de 2009 16h36min05s Horário Mundo (GMT)')
        self.assertEqual(
            i18n.format_datetime(value, format='full'),
            u'ter\xe7a-feira, 10 de novembro de 2009 16h36min05s GMT+00:00')
예제 #5
0
    def test_format_iso(self):
        value = datetime.datetime(2009, 11, 10, 16, 36, 05)

        self.assertEqual(i18n.format_date(value, format='iso'), u'2009-11-10')
        self.assertEqual(i18n.format_time(value, format='iso'), u'16:36:05')
        self.assertEqual(i18n.format_datetime(value, format='iso'),
                         u'2009-11-10T16:36:05+0000')
예제 #6
0
    def test_format_datetime(self):
        value = datetime.datetime(2009, 11, 10, 16, 36, 05)

        self.assertEqual(i18n.format_datetime(value, format='short'),
                         u'11/10/09 4:36 PM')
        self.assertEqual(i18n.format_datetime(value, format='medium'),
                         u'Nov 10, 2009 4:36:05 PM')
        self.assertEqual(i18n.format_datetime(value, format='long'),
                         u'November 10, 2009 4:36:05 PM +0000')
        #self.assertEqual(i18n.format_datetime(value, format='full'), u'Tuesday, November 10, 2009 4:36:05 PM World (GMT) Time')
        self.assertEqual(i18n.format_datetime(value, format='full'),
                         u'Tuesday, November 10, 2009 4:36:05 PM GMT+00:00')

        i18n.get_i18n().set_timezone('America/Chicago')
        self.assertEqual(i18n.format_datetime(value, format='short'),
                         u'11/10/09 10:36 AM')
예제 #7
0
    def test_format_iso(self):
        value = datetime.datetime(2009, 11, 10, 16, 36, 05)

        self.assertEqual(i18n.format_date(value, format='iso'), u'2009-11-10')
        self.assertEqual(i18n.format_time(value, format='iso'), u'16:36:05')
        self.assertEqual(
            i18n.format_datetime(value, format='iso'),
            u'2009-11-10T16:36:05+0000')
예제 #8
0
    def test_format_iso(self):
        value = datetime.datetime(2009, 11, 10, 16, 36, 5)

        self.assertEqual(i18n.format_date(value, format="iso"), "2009-11-10")
        self.assertEqual(i18n.format_time(value, format="iso"), "16:36:05")
        self.assertEqual(
            i18n.format_datetime(value, format="iso"), "2009-11-10T16:36:05+0000"
        )
예제 #9
0
 def _value(self):
     if self.raw_data:
         return u' '.join(self.raw_data)
     else:
         if self.data:
             logging.info( "DATA %s" % self.data)
             # format data rebases to local timezone
             return format_datetime(self.data)
         else:
             return u''
예제 #10
0
 def _value(self):
     if self.raw_data:
         return u' '.join(self.raw_data)
     else:
         if self.data:
             logging.info("DATA %s" % self.data)
             # format data rebases to local timezone
             return format_datetime(self.data)
         else:
             return u''
예제 #11
0
    def test_format_datetime_pt_BR(self):
        i18n.get_i18n().set_locale("pt_BR")
        value = datetime.datetime(2009, 11, 10, 16, 36, 5)

        self.assertEqual(i18n.format_datetime(value, format="short"), "10/11/09 16:36")
        self.assertEqual(
            i18n.format_datetime(value, format="medium"), "10 de nov de 2009 16:36:05"
        )
        # self.assertEqual(i18n.format_datetime(value, format='long'),
        # u'10 de novembro de 2009 16:36:05 +0000')
        self.assertEqual(
            i18n.format_datetime(value, format="long"),
            "10 de novembro de 2009 16:36:05 +0000",
        )
        # self.assertEqual(i18n.format_datetime(value, format='full'),
        # u'terça-feira, 10 de novembro de 2009
        # 16h36min05s Horário Mundo (GMT)')
        self.assertEqual(
            i18n.format_datetime(value, format="full"),
            "ter\xe7a-feira, 10 de novembro de 2009 16:36:05 GMT+00:00",
        )
예제 #12
0
 def test_format_datetime_no_format(self):
     value = datetime.datetime(2009, 11, 10, 16, 36, 05)
     self.assertEqual(
         i18n.format_datetime(value), u'Nov 10, 2009 4:36:05 PM')
예제 #13
0
파일: time.py 프로젝트: phiiil/veosan
def format_datetime_noseconds(datetime):
    if datetime:
        return format_datetime(datetime, "yyyy-MM-dd H:mm")
    else:
        ""
예제 #14
0
 def localize_field(self, value):
     if value:
         datetime = i18n.to_local_timezone(value)
         return i18n.format_datetime(datetime, _("MM/dd/YYYY HH:mm:ss"))
     return super(DateTimeField, self).localize_field(value)
예제 #15
0
파일: time.py 프로젝트: phiiil/veosan
def format_datetime_withseconds_convert_east_tz(datetime):
    return format_datetime(datetime, "yyyy-MM-dd H:mm:ss", rebase=True)
예제 #16
0
파일: time.py 프로젝트: phiiil/veosan
def format_datetime_full(datetime):
    lang = _('en')
    if (lang == 'fr'):
        return "%s %s %s" % (format_datetime(datetime, "EEEE 'le' d MMMM yyyy"), _(u"at"), format_datetime(datetime, "H:mm"))
    else:
        return "%s %s %s" % (format_datetime(datetime, "EEEE d MMMM yyyy"), _(u"at"), format_datetime(datetime, "H:mm a"))
예제 #17
0
 def test_format_datetime_no_format(self):
     value = datetime.datetime(2009, 11, 10, 16, 36, 05)
     self.assertEqual(i18n.format_datetime(value),
                      u'Nov 10, 2009 4:36:05 PM')
예제 #18
0
파일: time.py 프로젝트: phiiil/veosan
def format_datetime_booking_form(datetime):
    return format_datetime(datetime, "yyyy-MM-dd H:mm:ss", rebase=False)
예제 #19
0
 def localize_field(self, value):
     if value:
         datetime = i18n.to_local_timezone(value)
         return i18n.format_datetime(datetime, _('MM/dd/YYYY HH:mm:ss'))
     return super(DateTimeField, self).localize_field(value)