-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Format created of transaction with date time value if the created date is the current date #34784
Changes from 2 commits
d3998d4
030d802
1e0bb54
56b9b5b
ac00d37
120c9ce
e7642f6
4908662
6e49257
8e7dc14
b25f0c7
e3472ec
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -730,6 +730,15 @@ function formatToSupportedTimezone(timezoneInput: Timezone): Timezone { | |
}; | ||
} | ||
|
||
/** | ||
* Return the date with full format if the created date is the current date. | ||
* Otherwise return the created date. | ||
*/ | ||
function enrichMoneyRequestTimestamp(created: string) { | ||
const currentTime = getDBTime(); | ||
return isSameDay(new Date(created), new Date(currentTime)) ? currentTime : created; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please test if it works when dropping the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IsSameDay only apply type number and Date. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, it does on There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's some active discussion, but it won't be actionable for this PR. We're good here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we might have some timezone issues here...
I think what happens here is a round-trip of date conversions: local -> UTC -> local, or something like that... We should do something like this if I'm not mistaken. const now = new Date();
return isSameDate(new Date(created), now) ? getDBTimeFromDate(now) : created;
|
||
} | ||
|
||
const DateUtils = { | ||
formatToDayOfWeek, | ||
formatToLongDateWithWeekday, | ||
|
@@ -774,6 +783,7 @@ const DateUtils = { | |
getWeekEndsOn, | ||
isTimeAtLeastOneMinuteInFuture, | ||
formatToSupportedTimezone, | ||
enrichMoneyRequestTimestamp, | ||
}; | ||
|
||
export default DateUtils; |
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.
Please state the return type explicitly
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.
@cubuspl42 I updated the return type.