-
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 8 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 |
---|---|---|
|
@@ -360,12 +360,19 @@ function getMicroseconds(): number { | |
return Date.now() * CONST.MICROSECONDS_PER_MS; | ||
} | ||
|
||
/** | ||
* Returns the format yyyy-MM-dd HH:mm:ss of a date in the format expected by the database | ||
*/ | ||
function getDBTimeFromDate(date: Date): string { | ||
return date.toISOString().replace('T', ' ').replace('Z', ''); | ||
} | ||
|
||
/** | ||
* Returns the current time in milliseconds in the format expected by the database | ||
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. /**
* Convert the given timestamp to the "yyyy-MM-dd HH:mm:ss" format, as expected by the database
*
* @param [timestamp] the given timestamp (if omitted, defaults to the current time)
*/ |
||
*/ | ||
function getDBTime(timestamp: string | number = ''): string { | ||
const datetime = timestamp ? new Date(timestamp) : new Date(); | ||
return datetime.toISOString().replace('T', ' ').replace('Z', ''); | ||
return getDBTimeFromDate(datetime); | ||
} | ||
|
||
/** | ||
|
@@ -733,6 +740,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): string { | ||
const now = new Date(); | ||
const createdDate = parse(created, CONST.DATE.FNS_FORMAT_STRING, now); | ||
return isSameDay(createdDate, now) ? getDBTimeFromDate(now) : created; | ||
} | ||
/** | ||
* Returns the last business day of given date month | ||
* | ||
|
@@ -796,6 +812,7 @@ const DateUtils = { | |
getWeekEndsOn, | ||
isTimeAtLeastOneMinuteInFuture, | ||
formatToSupportedTimezone, | ||
enrichMoneyRequestTimestamp, | ||
getLastBusinessDayOfMonth, | ||
}; | ||
|
||
|
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.
Okey, let's nuke this comment (as it's a helper function related to
getDBTime
) and update the original comment so it makes sense.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.
👉 #34784 (comment)
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.
I didn't realize that you aren't the author of the phrase I commented earlier
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.
Sound good, updated the comment.