You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: cp-7.58.0 formatTimeRemaining to correctly display time remaining (#21843)
## **Description**
Right now the rewards component that displays the number of time left is
incorrectly showing the time left if the hours value returned by
`getTimeDifferenceFromNow` is 0. (it will only show minutes left in this
case) This will happen if the end date of the season versus the current
time on the app is X day(s) 0 hours and X minute(s).
## **Changelog**
CHANGELOG entry: fix rewards season time remaining
## **Related issues**
Fixes: #21842
## **Screenshots/Recordings**
<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->
### **Before**
<img width="654" height="206" alt="image"
src="https://github.com/user-attachments/assets/353da666-7a10-4433-b6fd-1e08bf88309d"
/>
### **After**
<img width="656" height="273" alt="image"
src="https://github.com/user-attachments/assets/3a36bfa3-6c26-4966-b4ab-c9c09f865fc4"
/>
## **Pre-merge author checklist**
- [x] I’ve followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile
Coding
Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md).
- [x] I've completed the PR template to the best of my ability
- [x] I’ve included tests if applicable
- [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [x] I’ve applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.
## **Pre-merge reviewer checklist**
- [x] I've manually tested the PR (e.g. pull and build branch, run the
app, test code being changed).
- [x] I confirm that this PR addresses all acceptance criteria described
in the ticket it closes and includes the necessary testing evidence such
as recordings and or screenshots.
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> Adjust time-remaining formatting to include days/hours/minutes with
stricter null conditions and update tests, plus locale checks for
rewards date formatting.
>
> - **Utilities**:
> - Update `formatTimeRemaining` to compose output from `days`, `hours`,
and `minutes`, trim trailing space, and return `null` only when all are
non-positive.
> - **Tests**:
> - Revise and expand `formatUtils.test.ts` for new
`formatTimeRemaining` behavior (e.g., days+minutes, hours-only,
minutes-only, large diffs, zero/negative cases, trimming).
> - Add locale-aware checks for `formatRewardsDate` (default and custom
locales).
> - Maintain number formatting fallback test using mocked
`getIntlNumberFormatter`.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
a87305a. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
0 commit comments