Fix: Resolved the issue with parsing date and time for Chinese Kindle highlights (Issue #311)#331
Open
ProudBenzene wants to merge 3 commits into
Open
Fix: Resolved the issue with parsing date and time for Chinese Kindle highlights (Issue #311)#331ProudBenzene wants to merge 3 commits into
ProudBenzene wants to merge 3 commits into
Conversation
在 parseBooks.ts 中新增 convertChineseDateToEnglish 预处理函数, 将中文时间戳转换为英文格式后再传入第三方库解析。 支持以下中文日期格式: - 完整格式:2022年12月17日星期六 下午5:11:41 - 无星期:2021年8月28日 上午1:47:38 - 无时间:2024年12月31日 星期二 - 仅日期:2024年1月1日 - 支持「星期X」和「周X」两种星期表达
There was a problem hiding this comment.
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
convertChineseDateToEnglishthat transforms Chinese date/time strings into English format before parsing - Integrated the conversion into the existing
parseBooksfunction 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.
…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.
Author
|
I pushed a small follow-up update to keep this PR narrowly scoped as a bugfix. Changes made:
The goal here is still just to make the existing preprocessing more robust without changing the default flow beyond that. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In
parseBooks.ts, add a preprocessing function calledconvertChineseDateToEnglishthat converts Chinese timestamps into English format before passing them to the third-party library for parsing, which fixed #311