Skip to content

fix(ui): avoid timezone-ambiguous comment timestamps - #1166

Closed
awaae001 wants to merge 5 commits into
ArtalkJS:masterfrom
awaae001:fix/timezone-safe-timestamps
Closed

awaae001 wants to merge 5 commits into
ArtalkJS:masterfrom
awaae001:fix/timezone-safe-timestamps

Conversation

@awaae001

Copy link
Copy Markdown

Fix timezone-ambiguous comment timestamps by exposing timezone-safe timestamp fields and making the UI prefer them when rendering relative time.

Previously, the API returned date as a timezone-less string such as 2026-07-27 12:00:00. Browsers parse that as local time, so users in different timezones could see newly created comments as “1 hour ago” or keep seeing “now” when the parsed time falls in the future.

Link to: #1165

Changes

  • Add date_unix and date_utc to cooked comment/page API responses.
  • Keep the existing date field for backward compatibility.
  • Make the frontend prefer date_unix / date_utc before falling back to legacy date.
  • Update comment sorting and time ticking to use the same timestamp-safe parser.
  • Expose the new fields in email template data and Swagger docs.

Compatibility

This is backward compatible:

  • Existing date remains unchanged.
  • Existing clients can continue using the old field.
  • New clients can use date_unix or date_utc to avoid timezone ambiguity.
  • No database schema migration is required.

This PR was authored with the assistance of Codex.

@awaae001

Copy link
Copy Markdown
Author

@qwqcode 这个 PR 已经开启将近一个月有余,非常抱歉打扰,但是请您审阅这个 PR 并且给出修改意见(如果可能的话)
非常感谢

@awaae001
awaae001 force-pushed the fix/timezone-safe-timestamps branch from 49ef8a5 to 6dca77e Compare October 13, 2026 07:26
@awaae001
awaae001 force-pushed the fix/timezone-safe-timestamps branch from 6dca77e to 991db35 Compare October 13, 2026 07:29
@pull-request-size pull-request-size Bot added size/M and removed size/L labels Oct 13, 2026
Comment thread ui/artalk/src/lib/utils.ts Resolved
@pull-request-size pull-request-size Bot added size/L and removed size/M labels Oct 28, 2026
- Verify parseDate prioritizes date_unix over date_utc and preserves
  instants across UTC offset formats
- Ensure CommentNode display and date sorting stay consistent with
  parsed timestamps
- Add Go tests validating CookComment/CookPage serialize date_unix,
  date_utc, and legacy date fields consistently across timezones
@awaae001
awaae001 force-pushed the fix/timezone-safe-timestamps branch from 9ae0dc6 to 452a2bb Compare October 28, 2026 02:42
@awaae001

Copy link
Copy Markdown
Author

感谢您的建议
我已经按照您的要求添加了测试用例
同步了最新的代码
并且签名了本次的提交

@awaae001
awaae001 requested a review from dajiaohuang October 28, 2026 04:03

@dajiaohuang dajiaohuang left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding synthetic timestamp coverage. The current diff includes ui/artalk/tests/timestamps.test.ts cases for Unix timestamp precedence, equivalent RFC3339 offsets, legacy date fallback, comment display, and date sorting. I did not run this test or the suite in this pass, so this is source inspection only.

Scope note: compared with the previously reviewed head 991db350, the current head 452a2bbc adds nine commits and a broad set of authentication/guest-credential, OAuth, notification-ownership, and page-fetch security changes alongside the timestamp work. Please split these substantial non-timestamp changes into focused PRs, or clarify why they belong in this timestamp PR, before requesting approval. I am not approving the expanded change set.

@dajiaohuang dajiaohuang left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correction to my prior comment: I conflated the nine-commit compare from the previously reviewed head with the current PR-versus-base diff. I checked the exact current PR files endpoint: it contains 12 files focused on timestamp serialization, parsing/display/sorting, and compatibility tests; the unrelated security/auth changes I mentioned are not part of the current PR diff. Please disregard my request to split those changes. I have not run the new tests or any suite, and I am not approving the PR in this source-only pass.

@awaae001

awaae001 commented Oct 28, 2026 •

Copy link
Copy Markdown
Author

?
如果我代码中有任何做的不对的地方,欢迎指出。
我会在我空闲时间进行修改

如果我的评论给您带来了任何困扰,在这里致歉

@awaae001 awaae001 closed this Oct 28, 2026
@awaae001

Copy link
Copy Markdown
Author

我会择日另行重新开启此请求

@dajiaohuang

Copy link
Copy Markdown

你的评论没有给我带来困扰;抱歉是我此前的错误审阅造成了困惑。我把从旧审阅 head 到当前 head 的比较误当成当前 PR 相对 base 的变更,才错误要求拆分安全/认证改动。我已在后续 COMMENTED review 5677810023 撤回该要求。

按当前 PR-vs-base 的 12 个文件,我没有确认出可具体指出的代码缺陷。这次只检查了新增测试的源码,没有运行测试,因此不能说测试已通过。你不需要基于我那条已撤回的拆分请求做修改。谢谢你补充时间戳测试。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants