Refactor micro time to use a rounded duration#226
Merged
Conversation
this isn't spec compliant but it can make the codebase simpler
`micro` time can be more easily expressed using `Duration`. This will also make it locale aware.
|
👋 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.
|
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is a big refactor of the
microformat, 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:
microformat is now likeelapsedbut with some extra logic. This pairs down a lot of the complexity we had with the format.microformat is now somewhat easier to deprecate, which is our intent with v5.Durationobject which is a ponyfill forTemporal.Duration, and so one day can be deleted (perhaps a v6 version 😉)timeAgoandtimeUntilfunctions 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,7dwill all now become1w). Days are rounded to months, so31dis1m, and days are now rounded to years (so364dbecomes1y).