MetaMask / MetaMask/metamask-extension

[P2] util.js: relocate date/time formatters to a new date module

Open
#44,560 1 comment 0 reactions 0 assignees View on GitHub
for-migration INVALID-ISSUE-TEMPLATE mig-epic-70-child ta-triaged team-extension-platform
Dominant language
TypeScript
Stars
13.2k
Forks
5.6k
Avg merge
2d 5h
Merged PRs (30d)
451

Description

**Parent Epic:** [#44552 — `util.js` decomposition](https://github.com/MetaMask/metamask-extension/issues/44552)
**Source:** `ui/helpers/utils/util.js`
**Size:** M

---

## Problem

`formatDate` (fan-out ~9), `formatUTCDateFromUnixTimestamp`, `formatDateWithYearContext`, `toHumanReadableTime` — Luxon-based formatters with no existing date-module home. `toHumanReadableTime` takes the i18n `t` fn (UI-coupled).

## Solution

Create `ui/helpers/utils/date.ts` (TypeScript) and move the formatters there (keep `toHumanReadableTime` UI-side via `t`). Codemod the ~9 `formatDate` import sites.

## Acceptance Criteria

- [ ] New `ui/helpers/utils/date.ts`; formatters moved; originals deleted; imports rewired. Tests green.

Contributor guide

Open the contributing guide

Research direction

Start with ui/helpers/utils/util.js and trace the roughly nine formatDate import sites, then review the existing formatter tests before creating ui/helpers/utils/date.ts. Done means the four formatters are moved, originals are deleted, imports are rewired, and the test suite is green.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend
Issue type
Refactor
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
67/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.