Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 6 additions & 17 deletions py4web/utils/grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -397,15 +397,8 @@ def datetime_represent(value):
if not value or not isinstance(value, datetime.datetime):
return value or ""
return XML(
"<script>document.write((new Date(%s,%s,%s,%s,%s,%s)).toLocaleString())</script>"
% (
value.year,
value.month - 1,
value.day,
value.hour,
value.minute,
value.second,
)
"<script>document.currentScript.insertAdjacentText('afterend',"
f"(new Date('{value.isoformat(timespec='seconds')}')).toLocaleString())</script>"
)


Expand All @@ -414,12 +407,8 @@ def date_represent(value):
if not value or not isinstance(value, datetime.date):
return value or ""
return XML(
'<script>document.write((new Date(%s,%s,%s)).toLocaleString().split(",")[0])</script>'
% (
value.year,
value.month - 1,
value.day,
)
"<script>document.currentScript.insertAdjacentText('afterend',"
f"(new Date('{value.isoformat()}')).toLocaleDateString())</script>"
)


Expand All @@ -428,8 +417,8 @@ def time_represent(value):
if not value or not isinstance(value, datetime.time):
return value or ""
return XML(
"<script>document.write((new Date(0, 0, 0,%s,%s,%s)).toLocaleString().split(', ')[1])</script>"
% (value.hour, value.minute, value.second)
"<script>document.currentScript.insertAdjacentText('afterend',"
f"(new Date('0000T{value.isoformat('seconds')}')).toLocaleTimeString())</script>"
)


Expand Down