-
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
Merged
Merged
Changes from 7 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
d3998d4
format created of transaction with date time value if the created dat…
dukenv0307 030d802
implement util function for get current date of money request
dukenv0307 1e0bb54
add return type explicitly
dukenv0307 56b9b5b
Merge branch 'main' into fix/33814
dukenv0307 ac00d37
Merge branch 'main' into fix/33814
dukenv0307 120c9ce
convert to the same timezone before compare
dukenv0307 e7642f6
refactor compare date logic
dukenv0307 4908662
merge main and edit comment
dukenv0307 6e49257
edit the original comment
dukenv0307 8e7dc14
Merge branch 'main' into fix/33814
dukenv0307 b25f0c7
merge main
dukenv0307 e3472ec
Merge branch 'main' into fix/33814
dukenv0307 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 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 |
---|---|---|
|
@@ -730,6 +730,23 @@ function formatToSupportedTimezone(timezoneInput: Timezone): Timezone { | |
}; | ||
} | ||
|
||
/** | ||
* Returns the time in milliseconds of a date in the format expected by the database | ||
*/ | ||
function getDBTimeFromDate(date: Date): string { | ||
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. Well, please use it inside 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. Updated to use |
||
return date.toISOString().replace('T', ' ').replace('Z', ''); | ||
} | ||
|
||
/** | ||
* Return the date with full format if the created date is the current date. | ||
* Otherwise return the created date. | ||
*/ | ||
function enrichMoneyRequestTimestamp(created: string): string { | ||
const now = new Date(); | ||
const createdDate = parse(created, CONST.DATE.FNS_FORMAT_STRING, now); | ||
return isSameDay(createdDate, now) ? getDBTimeFromDate(now) : created; | ||
} | ||
|
||
const DateUtils = { | ||
formatToDayOfWeek, | ||
formatToLongDateWithWeekday, | ||
|
@@ -774,6 +791,7 @@ const DateUtils = { | |
getWeekEndsOn, | ||
isTimeAtLeastOneMinuteInFuture, | ||
formatToSupportedTimezone, | ||
enrichMoneyRequestTimestamp, | ||
}; | ||
|
||
export default DateUtils; |
This file contains 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
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.
Time in milliseconds?
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.
Updated comment.