Skip to content
Merged
Show file tree
Hide file tree
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
11 changes: 10 additions & 1 deletion static/js/task.js
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,16 @@ function formatUserDateTime(value) {
return '--/--/---- --:--';
}

const parsedDate = new Date(value);
let normalizedValue = value;
if (typeof normalizedValue === 'string') {
const trimmed = normalizedValue.trim();
const hasTimezone = /(?:Z|[+-]\d{2}:\d{2})$/i.test(trimmed);
if (!hasTimezone) {
normalizedValue = `${trimmed.replace(' ', 'T')}Z`;
}
}

const parsedDate = new Date(normalizedValue);
if (Number.isNaN(parsedDate.getTime())) {
return '--/--/---- --:--';
}
Expand Down
2 changes: 2 additions & 0 deletions task_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,8 @@ def __datetime_to_iso(value) -> str | None:
if value is None:
return None
if isinstance(value, datetime):
if value.tzinfo is None:
value = value.replace(tzinfo=timezone.utc)
return value.isoformat()
return str(value)

Expand Down
6 changes: 5 additions & 1 deletion user_dao.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from math import floor
import tasklists
from dataclasses import dataclass
from datetime import datetime
from datetime import datetime, timezone
from bson.objectid import ObjectId
from task_types import UserTaskList, TierProgress, UserCompletedTask, UserCurrentTask, TaskData, PageTask, CollectionLogVerificationData

Expand Down Expand Up @@ -116,6 +116,8 @@ def completed_date_to_iso(value) -> str | None:
if value is None:
return None
if isinstance(value, datetime):
if value.tzinfo is None:
value = value.replace(tzinfo=timezone.utc)
return value.isoformat()
if isinstance(value, str):
parsed = None
Expand All @@ -124,6 +126,8 @@ def completed_date_to_iso(value) -> str | None:
except ValueError:
pass
if parsed is not None:
if parsed.tzinfo is None:
parsed = parsed.replace(tzinfo=timezone.utc)
return parsed.isoformat()
return value
return str(value)
Expand Down