예제 #1
0
파일: tests.py 프로젝트: sm6xmm/flask-babel
    def test_basics(self):
        app = flask.Flask(__name__)
        b = babel.Babel(app)
        d = datetime(2010, 4, 12, 13, 46)

        with app.test_request_context():
            assert babel.format_datetime(d) == "Apr 12, 2010 1:46:00 PM"
            assert babel.format_date(d) == "Apr 12, 2010"
            assert babel.format_time(d) == "1:46:00 PM"

        with app.test_request_context():
            app.config["BABEL_DEFAULT_TIMEZONE"] = "Europe/Vienna"
            assert babel.format_datetime(d) == "Apr 12, 2010 3:46:00 PM"
            assert babel.format_date(d) == "Apr 12, 2010"
            assert babel.format_time(d) == "3:46:00 PM"

        with app.test_request_context():
            app.config["BABEL_DEFAULT_LOCALE"] = "de_DE"
            assert babel.format_datetime(d, "long") == "12. April 2010 15:46:00 MESZ"
예제 #2
0
    def test_basics(self):
        app = flask.Flask(__name__)
        b = babel.Babel(app)
        d = datetime(2010, 4, 12, 13, 46)

        with app.test_request_context():
            assert babel.format_datetime(d) == 'Apr 12, 2010 1:46:00 PM'
            assert babel.format_date(d) == 'Apr 12, 2010'
            assert babel.format_time(d) == '1:46:00 PM'

        with app.test_request_context():
            app.config['BABEL_DEFAULT_TIMEZONE'] = 'Europe/Vienna'
            assert babel.format_datetime(d) == 'Apr 12, 2010 3:46:00 PM'
            assert babel.format_date(d) == 'Apr 12, 2010'
            assert babel.format_time(d) == '3:46:00 PM'

        with app.test_request_context():
            app.config['BABEL_DEFAULT_LOCALE'] = 'de_DE'
            assert babel.format_datetime(d, 'long') == \
                '12. April 2010 15:46:00 MESZ'
예제 #3
0
    def test_basics(self):
        app = flask.Flask(__name__)
        b = babel.Babel(app)
        d = datetime(2010, 4, 12, 13, 46)

        with app.test_request_context():
            assert babel.format_datetime(d) == 'Apr 12, 2010 1:46:00 PM'
            assert babel.format_date(d) == 'Apr 12, 2010'
            assert babel.format_time(d) == '1:46:00 PM'

        with app.test_request_context():
            app.config['BABEL_DEFAULT_TIMEZONE'] = 'Europe/Vienna'
            assert babel.format_datetime(d) == 'Apr 12, 2010 3:46:00 PM'
            assert babel.format_date(d) == 'Apr 12, 2010'
            assert babel.format_time(d) == '3:46:00 PM'

        with app.test_request_context():
            app.config['BABEL_DEFAULT_LOCALE'] = 'de_DE'
            assert babel.format_datetime(d, 'long') == \
                '12. April 2010 15:46:00 MESZ'
예제 #4
0
파일: models.py 프로젝트: marcusti/times
 def get_formatted_end_time(self):
     if self.end_time:
         return format_time(self.end_time, format='HH:mm', rebase=False)
     else:
         return ''