def test_convert_bad_to_dategui_en(self):
     """dateutils - conversion of bad text date into English GUI date"""
     datetext = "2006-02-AA 18:36:01"
     dategui_en_expected = "N/A"
     dategui_en = dateutils.convert_datetext_to_dategui(datetext,
                                                        ln='en')
     self.assertEqual(dategui_en, dategui_en_expected)
 def test_convert_good_to_dategui_en(self):
     """dateutils - conversion of good text date into English GUI date
     """
     datetext = "2006-07-16 18:36:01"
     dategui_en_expected = "16 Jul 2006, 18:36"
     dategui_en = dateutils.convert_datetext_to_dategui(datetext, ln="en")
     self.assertEqual(dategui_en, dategui_en_expected)
 def test_convert_good_to_dategui_sk(self):
     """dateutils - conversion of good text date into Slovak GUI date"""
     datetext = "2006-07-16 18:36:01"
     dategui_sk_expected = "16 júl 2006, 18:36"
     dategui_sk = dateutils.convert_datetext_to_dategui(datetext,
                                                        ln='sk')
     self.assertEqual(dategui_sk, dategui_sk_expected)
 def test_convert_bad_to_dategui_sk(self):
     """dateutils - conversion of bad text date into Slovak GUI date"""
     from invenio_base.i18n import gettext_set_language
     ln = 'sk'
     _ = gettext_set_language(ln)
     datetext = "2006-02-AA 18:36:01"
     dategui_sk_expected = _('N/A')
     dategui_sk = dateutils.convert_datetext_to_dategui(datetext,
                                                        ln=ln)
     self.assertEqual(dategui_sk, dategui_sk_expected)
    def test_convert_bad_to_dategui_sk(self):
        """dateutils - conversion of bad text date into Slovak GUI date"""
        from invenio_base.i18n import gettext_set_language

        ln = "sk"
        _ = gettext_set_language(ln)
        datetext = "2006-02-AA 18:36:01"
        dategui_sk_expected = _("N/A")
        dategui_sk = dateutils.convert_datetext_to_dategui(datetext)
        assert dategui_sk == dategui_sk_expected
Beispiel #6
0
    def _format_date(date):
        """
        Format a date into a human friendly format.

        It uses :py:func:`invenio.utils.date.convert_datetext_to_dategui`
        """
        if isinstance(date, datetime):
            return convert_datestruct_to_dategui(
                date.timetuple(),
                getattr(g, 'ln', app.config['CFG_SITE_LANG'])).decode('utf-8')
        return convert_datetext_to_dategui(
            date, getattr(g, 'ln', app.config['CFG_SITE_LANG'])
        ).decode('utf-8')
Beispiel #7
0
    def _format_date(date):
        """
        Format a date into a human friendly format.

        It uses :py:func:`invenio.utils.date.convert_datetext_to_dategui`
        """
        from invenio_utils.date import convert_datetext_to_dategui
        if isinstance(date, datetime):
            return convert_datestruct_to_dategui(
                date.timetuple(),
                getattr(g, 'ln', app.config['CFG_SITE_LANG'])).decode('utf-8')
        return convert_datetext_to_dategui(
            date, getattr(g, 'ln', app.config['CFG_SITE_LANG'])
        ).decode('utf-8')
 def test_convert_good_to_dategui_sk(self):
     """dateutils - conversion of good text date into Slovak GUI date"""
     datetext = "2006-07-16 18:36:01"
     dategui_sk_expected = u"16 júl 2006, 18:36"
     dategui_sk = dateutils.convert_datetext_to_dategui(datetext)
     assert dategui_sk == dategui_sk_expected