Closed Bug 1184265 Opened 5 years ago Closed 2 years ago

Make last sync date be relative


(Firefox :: Sync, enhancement)

Not set



Firefox 61
61.2 - Apr 9
Tracking Status
firefox61 --- fixed


(Reporter: rfeeley, Assigned: eoger)




(2 files)

Attached image relative-dates.gif
Instead of showing an abbreviate day and time in the tooltip, perhaps we can instead show relative time.

Last sync:

Just now
2 secs ago
1 min ago
3 mins ago
1 hour ago
4 hours ago
1 day ago
5 days ago
1 week ago
6 weeks ago
1 month ago
7 months ago
1 year ago
7 years ago
If we can't do this, I can settle for "Today" and "Yesterday".
Depends on: 1186262
Assignee: edouard.oger → nobody
Flags: firefox-backlog+
Priority: -- → P3
See Also: → 1245505
Duplicate of this bug: 998856
Severity: normal → enhancement
Priority: P3 → --
Duplicate of this bug: 933516
See Also: → 1417403
Depends on: 1407240
No longer depends on: 1186262
Iteration: --- → 61.2 - Apr 9
Assignee: nobody → eoger
Quick note: we don't update the title on |mouseover| in the page action menu since we don't really expect that menu to be open for long.
Comment on attachment 8960787 [details]
Bug 1184265 - Make last sync date be relative.

::: browser/base/content/browser-sync.js:646
(Diff revision 1)
>    formatLastSyncDate(date) {
> -    let sixDaysAgo = (() => {
> -      let tempDate = new Date();
> -      tempDate.setDate(tempDate.getDate() - 6);
> -      tempDate.setHours(0, 0, 0, 0);
> -      return tempDate;
> +    if (!date) { // Date can be null before the first sync!
> +      return null;
> +    }
> +    const relativeDateStr = this.relativeTimeFormat.formatBestUnit(date);
> +    return this.syncStrings.formatStringFromName("lastSync2.label", [relativeDateStr], 1);

Note that the comment for this string should be updated - it mentions "%S is the date and time at which the last sync successfully completed"

We should probably get feedback from Flod too, just in-case some locales might want to change the string given this change (ie, whether we should rename the string to force localizers to notice)
Attachment #8960787 - Flags: review?(markh) → review+
Francesco are you okay with the changes here?
We are switching from:
- Last Sync: Tuesday 9:28PM
- Last Sync: March 12


- Last Sync: <new Services.intl.RelativeTimeFormat.formatBestUnit()>

Do we need a string change for |lastSync2.label|?
Flags: needinfo?(francesco.lodolo)
I think we're good keeping the existing string. All locales are following the English structure, as far as I see, so the different date format doesn't need a change.
Flags: needinfo?(francesco.lodolo)
Hey all! Cool to see the the use of Intl.RTF!

Two notes on the patch:

1) The way you currently use the formatter will give you things like "3 minutes ago". If you want "3 min. ago" switch to: `new Services.intl.RelativeTimeFormat(undefined, {style: "short"});`. (I'd recommend it based on the limited space in the UI)

2) The way you test it doesn't use any anchor. I think it may end up becoming an intermittent if you'll ever want to test particular values out of your UI since the time may pass between the moment you format and the moment you test. I don't see anything testing for particular values (good!), but wanted to raise it just in case you'll be also working with tests around it later :)
Thanks for the feedback everyone!
I've also confirmed with Ryan that we want the short style.
Pushed by
Make last sync date be relative. r=markh
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 61
Depends on: 1447829
You need to log in before you can comment on or make changes to this bug.