Allow customization of time format #22339
Open
+58
−10
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.
Proposed change
This change adds the ability to use alternative (i.e. shorter) forms for time values where
state-display
is used. My primary goal was to make my badges that showed relative time a bit more concise. However, I think it could be generally useful anywhere that these formatted time strings are used (hence the expansion to the tile card).I'm not really sold on the name of the property though;
time_verbosity
seems a bit clunky. Perhapstime_format
orrelative_time_format
are more appropriate. I originally avoided those names because I did see a few other time-format-related props and didn't want to add confusion. If you have a better name for this property, I'd be more than happy to change it!Also, I wanted to bring up the fact that the positional arguments to
relativeTime
are becoming more unwieldy with this addition. I thought about migrating to named props, butrelativeTime
is used somewhat extensively throughout the codebase and I didn't want to introduce such a large change without getting feedback from the team first.Other thoughts:
state_content
pieces.Type of change
Example configuration
Badge config (also works on
tile
cards):Additional information
Checklist
If user exposed functionality or configuration variables are added/changed: