Skip to content

Refactor micro time to use a rounded duration#226

Merged
keithamus merged 13 commits intomainfrom
refactor-micro-time-to-use-a-rounded-duration
Dec 8, 2022
Merged

Refactor micro time to use a rounded duration#226
keithamus merged 13 commits intomainfrom
refactor-micro-time-to-use-a-rounded-duration

Conversation

@keithamus
Copy link
Copy Markdown
Contributor

This is a big refactor of the micro format, to remove our rather strange rounding logic and instead use Duration with some logic which is a bit easier to reason about (and potentially easier to delete).

The main benefit here is that:

  1. micro format is now like elapsed but with some extra logic. This pairs down a lot of the complexity we had with the format.
  2. The micro format is now somewhat easier to deprecate, which is our intent with v5.
  3. The format relies more on our Duration object which is a ponyfill for Temporal.Duration, and so one day can be deleted (perhaps a v6 version 😉)
  4. This lays ground work for us to better refactor the timeAgo and timeUntil functions which just need to be wrangled to use the same rounding logic.

It should be noted that this does change some tests! Mostly around the ways with which the micro format gets displayed. Units are rounded up in what might be considered more expected ways. Week units are introduced (so 4d, 5d, 6d, 7d will all now become 1w). Days are rounded to months, so 31d is 1m, and days are now rounded to years (so 364d becomes 1y).

@keithamus keithamus requested a review from a team as a code owner December 8, 2022 10:56
@primer-css
Copy link
Copy Markdown

👋 Hello and thanks for pinging us! This issue or PR has been added to our inbox and a Design Infrastructure first responder will review it soon.

  • 🎨 If this is a PR that includes a visual change, please make sure to add screenshots in the description or deploy this code to a lab machine with instructions for how to test.
  • If this is a PR that includes changes to an interaction, please include a video recording in the description.
  • ⚠️ If this is urgent, please visit us in #primer on Slack and tag the first responders listed in the channel topic.

@keithamus keithamus merged commit 73aa427 into main Dec 8, 2022
@keithamus keithamus mentioned this pull request Dec 8, 2022
@keithamus keithamus deleted the refactor-micro-time-to-use-a-rounded-duration branch December 16, 2022 08:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants