-
Notifications
You must be signed in to change notification settings - Fork 55
chore: use ICU for relative dateime formatting #1146
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Reviewer's GuideThis PR replaces manual string concatenation for relative date/time displays with ICU’s locale-aware RelativeDateTimeFormatter and SimpleDateFormat, adds utility converters between QString and icu::UnicodeString, and updates CMake and packaging to include ICU dependencies. Sequence Diagram: Relative Time Formatting with ICU in AppNotifyItemsequenceDiagram
title "Sequence Diagram: Relative Time Formatting with ICU in AppNotifyItem"
participant A as "AppNotifyItem"
participant RDF as "icu::RelativeDateTimeFormatter"
participant SDF as "icu::SimpleDateFormat"
participant Conv as "StringConversionUtils"
A ->> A: updateTime()
A ->> RDF: create(Locale::getDefault(), ..., UDAT_STYLE_LONG, ...)
alt If time is within minutes/hours (same day)
A ->> RDF: format(value, UDAT_DIRECTION_LAST, UDAT_RELATIVE_MINUTES/HOURS, result, status)
A ->> Conv: toQString(result)
Conv -->> A: formattedTime : QString
else If time is "Yesterday"
A ->> RDF: format(1, UDAT_DIRECTION_LAST, UDAT_RELATIVE_DAYS, dateResult, status)
A ->> SDF: create("HH:mm", Locale::getDefault(), status)
A ->> SDF: format(m_entity.cTime(), timeString, status)
A ->> RDF: combineDateAndTime(dateResult, timeString, combinedResult, status)
A ->> Conv: toQString(combinedResult)
Conv -->> A: formattedTime : QString
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @BLumia - I've reviewed your changes - here's some feedback:
- Consider moving the ICU RelativeDateTimeFormatter and SimpleDateFormat instances out of updateTime (e.g. as static or member variables) to avoid recreating them on every call and improve performance.
- After each ICU operation you should check UErrorCode (status and timeStatus) and handle or log errors to avoid silent formatting failures.
Here's what I looked at during the review
- 🟡 General issues: 4 issues found
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟢 Complexity: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
43dc5d8 to
56fd120
Compare
使用 ICU 提供相对时间格式的时间展示,避免拼接字符串造成不易于本地化 的问题. Log:
56fd120 to
0d0b3d9
Compare
deepin pr auto review关键摘要:
是否建议立即修改:
|
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: 18202781743, BLumia The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
使用 ICU 提供相对时间格式的时间展示,避免拼接字符串造成不易于本地化的问题.
Summary by Sourcery
Use ICU libraries to provide localized relative datetime formatting in notification items, replacing manual string concatenation for improved i18n support.
Enhancements:
Build: