diff --git a/CHANGELOG.md b/CHANGELOG.md index f1499d2cf..b927a1526 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ### Changed +- Always round down dates on claim previews for better yotube parity ([#3353](https://github.com/lbryio/lbry-desktop/pull/3353)) + ## [0.37.2] - [2019-11-21] ### Fixed diff --git a/ui/component/dateTime/view.jsx b/ui/component/dateTime/view.jsx index 581c7d678..3ee450866 100644 --- a/ui/component/dateTime/view.jsx +++ b/ui/component/dateTime/view.jsx @@ -19,7 +19,21 @@ class DateTime extends React.PureComponent { const show = this.props.show || DateTime.SHOW_BOTH; if (timeAgo) { - return date ? {moment(date).from(moment())} : ; + if (!date) { + return null; + } + + // Moment is very liberal with it's rounding + // Wait to show "two years ago" until it's actually been two years (or higher) + const numberOfYearsSincePublish = moment().diff(date, 'years'); + + if (numberOfYearsSincePublish === 1) { + return {__('%numberOfYearsSincePublish% year ago', { numberOfYearsSincePublish })}; + } else if (numberOfYearsSincePublish > 1) { + return {__('%numberOfYearsSincePublish% years ago', { numberOfYearsSincePublish })}; + } + + return {moment(date).from(moment())}; } return (