Skip to content
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

Update/formattime #101

Merged
merged 9 commits into from
Dec 16, 2024
Merged

Update/formattime #101

merged 9 commits into from
Dec 16, 2024

Conversation

capetillo
Copy link
Collaborator

Updates utils functions formatDate, formatTime, and formatDateMMDDYY into one:formatDateTime to further simplify the utility functionality.
Updates tests too

VISUALS

Date and time rendering as it should
Screenshot 2024-12-10 at 12 47 44 PM

@capetillo capetillo requested review from mgdaily, jnation3406 and LTDakin and removed request for mgdaily, jnation3406 and LTDakin December 10, 2024 21:00
const date = new Date(timeString)
const options = { hour: 'numeric', minute: 'numeric' }
return date.toLocaleTimeString('en-US', options)
if (options && (options.hour || options.minute)) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is the reasoning for wrapping the date's util functions instead of using them on their own? It might be simpler to just call them in the code, but if you had a reason for doing so then this code looks good

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it was the same function 3 times that formatted time in 3 different way so now it just takes the 2 values as params: the date string and options (i.e. how we want to format the time)

const date = new Date(timeString)
const options = { hour: 'numeric', minute: 'numeric' }
return date.toLocaleTimeString('en-US', options)
if (options && (options.hour || options.minute)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you comment this to say why we need this conditional statement, or what the correct format of options is? might help a future programmer. alternatively, you can expose the specific options keys as function parameters.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes I can do that!

@capetillo capetillo requested review from LTDakin and mgdaily December 16, 2024 20:55
@capetillo capetillo merged commit 6dfd699 into main Dec 16, 2024
1 check passed
@capetillo capetillo deleted the update/formattime branch December 16, 2024 22:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants