Make the date format user configurable

This commit is contained in:
2021-12-24 06:49:37 +00:00
parent 0fdfe811f8
commit 30543409e0
3 changed files with 8 additions and 1 deletions

View File

@@ -18,6 +18,8 @@ image:
env: env:
# -- Set the container timezone # -- Set the container timezone
TZ: UTC TZ: UTC
# -- Python date format string to use for rendering the date/time
DATE_FORMAT: "%Y-%m-%d %H:%M"
# -- Configures service settings for the chart. # -- Configures service settings for the chart.
# @default -- See values.yaml # @default -- See values.yaml

View File

@@ -94,6 +94,11 @@ def get_greeting():
return 'こんにちは' return 'こんにちは'
@base.app_template_filter()
def format_datetime(value, format='medium'):
return value.strftime(os.environ.get('DATE_FORMAT', '%Y-%m-%d %H:%M')) # noqa: WPS323
@base.route('/') @base.route('/')
def index(): def index():
return render_template('index.j2', return render_template('index.j2',

View File

@@ -53,7 +53,7 @@
<section id="header"> <section id="header">
<h1>{{ greeting | default("Welcome")}}</h1> <h1>{{ greeting | default("Welcome")}}</h1>
<h2>{{ now }}</h2> <h2>{{ now | format_datetime }}</h2>
</section> </section>
{% if applications %} {% if applications %}