Skip to content

Commit

Permalink
adds comment
Browse files Browse the repository at this point in the history
  • Loading branch information
capetillo committed Dec 16, 2024
1 parent a143932 commit 0be2646
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/utils/formatTime.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
// formats a date based on the options provided
function formatDateTime (dateString, options) {
const date = new Date(dateString)
// This condition is necessary because the toLocaleTimeString method does not accept the year, month, or day options
if (options && (options.hour || options.minute)) {
return date.toLocaleTimeString('en-US', options)
// And this condition is necessary because the toLocaleDateString method does not accept the hour or minute options
} else {
return date.toLocaleDateString('en-US', options)
}
Expand Down

0 comments on commit 0be2646

Please sign in to comment.