Skip to content

Commit

Permalink
Better cross-browser date display
Browse files Browse the repository at this point in the history
  • Loading branch information
katamartin committed May 30, 2024
1 parent 61010d1 commit a5a5ceb
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions components/date-display.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,8 @@ export const useDateGetter = (coordinate) => {

const getter = useCallback(
(v) => {
let dateString = startDate[0]
// append time to use local time zone if time is not already present
if (!dateString.match(/\d\d:\d\d/)) {
dateString = `${dateString} 12:00`
}
// Remove time and trim whitespace for simplest initialization across browsers
const dateString = startDate[0].replace(/\d\d(:\d\d)+/, '').trim()

const date = new Date(dateString)
date.setDate(date.getDate() + v)
Expand Down

0 comments on commit a5a5ceb

Please sign in to comment.