samblackk commented on a change in pull request #7693: [AIRFLOW-7046]
Locale-formatted datetimes (UI only)
URL: https://github.com/apache/airflow/pull/7693#discussion_r393786107
##########
File path: airflow/www/utils.py
##########
@@ -282,7 +289,18 @@ def dt(attr):
f = f.isoformat() if f else ''
if timezone.utcnow().isoformat()[:4] == f[:4]:
f = f[5:]
- return Markup("<nobr>{}</nobr>").format(f)
+ return Markup('<time datetime="{}">{}</time>').format(f, f)
+ return dt
+
+
+def localized_f(attr_name):
+ def dt(attr):
+ f = attr.get(attr_name)
+ if f is None:
+ return Markup('<time datetime="{}">{}</time>').format(f, f)
+ else:
+ f = f.strftime(date_format)
+ return Markup('<time datetime="{}">{}</time>').format(f, f)
Review comment:
Everything in this PR is converting client-side only from whatever format is
coming from the server. I'm not too familiar with Python so if there's a better
func to call to induce the formatting, I'd love to learn!
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services