-
Notifications
You must be signed in to change notification settings - Fork 28
Update date display to include year and fix consistency across list and details views #6405
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
4e7eed1
update date format
pa-lem 12c74b8
add fragment
pa-lem 7d18dfb
add util function
pa-lem e5e5363
show year only for dates before the current year
pa-lem 4d8942b
update fragment
pa-lem f71cdc0
Merge branch 'stable' into ple-dates
pa-lem 7bf5a0b
update date format
pa-lem File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Update date formatting to include the year for dates before the current year, and ensure consistency between the list and detail views. |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,15 @@ | ||
import { format, formatDistance } from "date-fns"; | ||
import { format, formatDistance, getYear } from "date-fns"; | ||
|
||
export const formatFullDate = (date: string | number | Date) => { | ||
export function formatFullDate(date: string | number | Date) { | ||
return format(date, "dd/MM/yyyy HH:mm"); | ||
}; | ||
} | ||
|
||
export const formatRelativeTimeFromNow = (date: number | Date) => { | ||
export function formatRelativeTimeFromNow(date: number | Date) { | ||
return formatDistance(date, new Date(), { addSuffix: true }); | ||
}; | ||
} | ||
|
||
export function isInPreviousYear(date: string | number | Date) { | ||
const currentYear = getYear(new Date()); | ||
const previousYear = currentYear - 1; | ||
return getYear(date) === previousYear; | ||
} |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why should we not display time anymore?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the goal is to make it consistent, it's a request from CS
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and there was no details in the previous format, with the component it will be more clear since we have the tooltip for the absolute value and it adapts depending on how old the date is