Skip to content

Commit 3c62c65

Browse files
committed
fix(pat display time): Fix relative time for timezone corner cases.
For date-only from-now, just use Intl.RelativeTimeFormat to avoid any timezone calculation mistakes. This prevents a case where in days in the future or past were shown as 9 days due to timezone differences in some circumstances.
1 parent 3d3e8c3 commit 3c62c65

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/pat/display-time/display-time.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,10 @@ export default Base.extend({
6161
lastDay: `[${rtf.format(-1, "day")}]`, // translates to "yesterday"
6262
sameDay: `[${rtf.format(0, "day")}]`, // translates to "today"
6363
nextDay: `[${rtf.format(1, "day")}]`, // translates to "tomorrow"
64-
nextWeek: "dddd",
65-
// when the date is further away, use from-now functionality
64+
nextWeek: "dddd", // translates to week day name
65+
// otherwise, just use Intl.RelativeTimeFormat.
6666
sameElse: () => {
67-
return `[${date.fromNow(this.options.noSuffix)}]`;
67+
return `[${rtf.format(date_diff, "day")}]`;
6868
},
6969
});
7070
} else {

0 commit comments

Comments
 (0)