-
Notifications
You must be signed in to change notification settings - Fork 309
lightbox: Use a friendlier format for the date, like "Yesterday at 4:47 PM" #45
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
Comments
@gnprice can i work on this? |
Sure. Do see our guide to picking an issue: so in particular before claiming an issue, you should have already gotten started working on it, finding the relevant piece of code and getting an idea of how you'll approach it. Also note this issue is in the "Post-launch" milestone, not "Launch" or earlier. That means the core team will have limited time to spend helping with this issue for the next few months. But I think the issue is simple enough that that should be fine. |
@gnprice I had a shot at this issue and is the result The device i am using is my Techno Spark 7 - Before making a PR, I would like to verify if a change like this would require that tests be made or updated? since I just added a method to the widget to format the date. In the course of solving this issue, i added localization to transform the time to the local of the user; it address #278 for this date. |
Changed the timestamp format from Mar 31, 2023 15:09:51 to a more readable Mar 31, 2023 at 3:09 PM. Added proper localization support to adapt timestamps to the user's language and region preferences. Optimized the timestamp logic to ensure accurate categorization into Today, Yesterday, or specific dates. Fixes: zulip#45
Hello, I have worked on the issue, Please review the changes and let me know if anything else is required. |
Hello, It would be great to receive some reviews on my PR. Looking forward for your response. |
Changed the timestamp format from Mar 31, 2023 15:09:51 to a more readable Mar 31, 2023 at 3:09 PM. Added proper localization support to adapt timestamps to the user's language and region preferences. Optimized the timestamp logic to ensure accurate categorization into Today, Yesterday, or specific dates. Fixes: zulip#45
I noticed this issue is still open and labeled as "help wanted". Has the existing PR been abandoned, or can I contribute to improving the solution? |
Thanks. In January we learned more about the options for how to implement this, which is reflected now in the issue description. Based on those updates, I think this no longer belongs as a "help wanted" issue That's because this is going to require as a prerequisite pulling in an ICU implementation via |
…or "A few seconds ago", etc.
Currently it shows something like "Mar 31, 2023 15:09:51".
Implementation (full solution)
It's possible that we'll want to merge a partial solution before implementing this, but anyway I wanted to write down some findings.
Dart
intl.DateFormat
doesn't support some desired features:We could work around, with our own code or maybe with a library in Dart (such as
timeago
orrelative_time
). But (1) is slightly tricky to implement, and requires giving more plural-syntax strings to our volunteer translators. For (2) we could just give the separator to our translators, but that feels unsatisfying because it shouldn't be necessary.I propose using an ICU library via ffi, which we already plan to do for other localization features: #1165 (comment)
DateFormat::createTimeInstance
with styleRELATIVE_SHORT
orRELATIVE_MEDIUM
. It should produce e.g. "21 minutes ago".Otherwise, use
DateFormat::createInstanceForSkeleton
, passing an appropriate "skeleton" (see this helpful explainer):time
, use skeletonjmm
, for "12:15 PM".MMMdjmm
, for "Jan 2 at 5:00 PM"yMMMdjmm
, for "Jan 2, 2024 at 5:00 PM".yMMMdjmm
. A relative time like "in 21 minutes" would be awkward here.The strings must be formatted with the same time zone and calendar (Gregorian, Chinese lunar, etc.) as we use to decide which day or year the timestamp is on. We should be able to choose an appropriate
Calendar
for the which-day/year calculation and pass thatCalendar
toDateFormat::createInstanceForSkeleton
.We should periodically force-rebuild the widget that shows the time, to avoid freezing with text like "1 minute ago".
We should offer a tooltip that shows the full date and time, with seconds, plus the timezone; skeleton
yMMMdjmmsszzzz
.The text was updated successfully, but these errors were encountered: