Skip to content

Fix: Resolved the issue with parsing date and time for Chinese Kindle highlights (Issue #311)#331

Open
ProudBenzene wants to merge 3 commits into
hadynz:masterfrom
ProudBenzene:ChineseTimestamp
Open

Fix: Resolved the issue with parsing date and time for Chinese Kindle highlights (Issue #311)#331
ProudBenzene wants to merge 3 commits into
hadynz:masterfrom
ProudBenzene:ChineseTimestamp

Conversation

@ProudBenzene
Copy link
Copy Markdown

In parseBooks.ts, add a preprocessing function called convertChineseDateToEnglish that converts Chinese timestamps into English format before passing them to the third-party library for parsing, which fixed #311

在 parseBooks.ts 中新增 convertChineseDateToEnglish 预处理函数,
将中文时间戳转换为英文格式后再传入第三方库解析。

支持以下中文日期格式:
- 完整格式:2022年12月17日星期六 下午5:11:41
- 无星期:2021年8月28日 上午1:47:38
- 无时间:2024年12月31日 星期二
- 仅日期:2024年1月1日
- 支持「星期X」和「周X」两种星期表达
Copilot AI review requested due to automatic review settings February 19, 2026 08:33
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes Issue #311 by adding support for parsing Chinese-formatted Kindle highlight timestamps. The issue occurred because the third-party library @hadynz/kindle-clippings couldn't parse Chinese date/time strings, resulting in incorrect createdDate values in imported highlights.

Changes:

  • Added a preprocessing function convertChineseDateToEnglish that transforms Chinese date/time strings into English format before parsing
  • Integrated the conversion into the existing parseBooks function to handle Chinese timestamps transparently
  • Added comprehensive documentation explaining the supported Chinese date formats

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/sync/syncClippings/parseBooks.ts Outdated
Comment thread src/sync/syncClippings/parseBooks.ts Outdated
Comment thread src/sync/syncClippings/parseBooks.ts
…z#311)

Add convertChineseDateToEnglish preprocessor in parseBooks.ts to convert
Chinese timestamps to English format before passing to the third-party
parsing library.

Supported Chinese date formats:
- Full: 2022年12月17日星期六 下午5:11:41
- Without weekday: 2021年8月28日 上午1:47:38
- Without time: 2024年12月31日 星期二
- Date only: 2024年1月1日
- Both 星期X and 周X weekday styles

# Conflicts:
#	src/sync/syncClippings/parseBooks.ts
Keep invalid month values unchanged, remove the non-English inline comment, and add focused coverage for supported Chinese timestamp formats and edge cases.
@ProudBenzene
Copy link
Copy Markdown
Author

I pushed a small follow-up update to keep this PR narrowly scoped as a bugfix.

Changes made:

  • added focused tests for the supported Chinese timestamp formats
  • kept invalid month values unchanged instead of producing a malformed result
  • removed the non-English inline comment for consistency with the codebase

The goal here is still just to make the existing preprocessing more robust without changing the default flow beyond that.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Chinese Timestamp of Annotations Imported Error

2 participants