firefox-devtools / firefox-devtools/profiler

The logic to choose a format for a date in the list of uploaded profiles isn't always great

Open
#4,851 3 comments 0 reactions 0 assignees View on GitHub
polish uploaded profiles
Dominant language
TypeScript
Stars
1.5k
Forks
491
Avg merge
3d 46m
Merged PRs (30d)
27

Description

At the URL https://profiler.firefox.com/uploaded-recordings/ we can see the list of uploaded profiles.

The current logic to choose the datetime format is:
https://github.com/firefox-devtools/profiler/blob/c60370e8c34c14b773d68959622f82bdcf1701ff/src/utils/l10n-ftl-functions.js#L64-L99

That is the current logic is:
1. if the date is less than 1 day old, display hours and minutes
2. otherwise, if the date is less than 1 year old, display day, month, hours and minutes
3. otherwise, display year, month and day

But this doesn't work great in some situations.

For example, if the date is 23h old, this will use the first format => to the user, it looks like this is in the future (for example, it is 4pm and it will show 5pm)
Another example: if the date is 11 months, 30 days old, this will use the 2nd format. For example it's Dec 13, 2023, 15:00, a profile was uploaded Dec 13, 2022 at 17:00, it will be displayed "Dec 13, 17:00".

**(Option A)** The best would probably be to relate to the current period:
1. if the date is _today_, display hours and minutes
2. otherwise, if the date is _this year_, display day, month, hours and minutes
3. otherwise display year month and day

But these comparisons might not be performant, because they need to take the local timezone into account.

**(Option B)** Another possibility is:
1. if the date is less than 12 hours old, display hours and minutes
2. otherwise, if the date is less than 6 months old, display day, month, hours and minutes
3. otherwise, display year, month and day

By using half periods, as a user it's much less likely that this will look like the future, even though the date is formally part of the previous period (that is, yesterday if it's 6am and the profile was uploaded at 10pm, or last year if we're in february and the profile was uploaded in september).

Therefore I think this possibility makes sense.

What do you think @canova ?

┆Issue is synchronized with this [Jira Task](https://mozilla-hub.atlassian.net/browse/FP-9)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.