mirror of
https://github.com/apache/superset.git
synced 2026-04-25 11:04:48 +00:00
fix: humanised changed on UTC on dashboards and charts (#10321)
* fix: API marshmallow3 drop utc for naive datetime fields * fix: API marshmallow3 drop utc for naive datetime fields * fix, tests * isort and test * black * add and fix test * fix comment
This commit is contained in:
committed by
GitHub
parent
ac85aebe4a
commit
74cb82e1ad
@@ -25,6 +25,7 @@ from typing import Any, Dict, List, Optional, Set, Union
|
||||
# pylint: disable=ungrouped-imports
|
||||
import humanize
|
||||
import pandas as pd
|
||||
import pytz
|
||||
import sqlalchemy as sa
|
||||
import yaml
|
||||
from flask import escape, g, Markup
|
||||
@@ -381,6 +382,15 @@ class AuditMixinNullable(AuditMixin):
|
||||
def changed_on_(self) -> Markup:
|
||||
return Markup(f'<span class="no-wrap">{self.changed_on}</span>')
|
||||
|
||||
@renders("changed_on")
|
||||
def changed_on_delta_humanized(self) -> str:
|
||||
return self.changed_on_humanized
|
||||
|
||||
@renders("changed_on")
|
||||
def changed_on_utc(self) -> str:
|
||||
# Convert naive datetime to UTC
|
||||
return self.changed_on.astimezone(pytz.utc).strftime("%Y-%m-%dT%H:%M:%S.%f%z")
|
||||
|
||||
@property
|
||||
def changed_on_humanized(self) -> str:
|
||||
return humanize.naturaltime(datetime.now() - self.changed_on)
|
||||
|
||||
Reference in New Issue
Block a user