Skip to content

Commit

Permalink
Use moment.js for getting an ISO date string
Browse files Browse the repository at this point in the history
Moment allows you to get a fate string based on local time which is
exactly what we need.
  • Loading branch information
lkiesow committed Jun 7, 2024
1 parent 93dc23b commit fafd097
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions src/utils/dateUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ import { makeTwoDigits } from "./utils";

// Get the ISO date string based on local time
const getISODateString = (date: Date) => {
const offsetHours = Math.trunc(date.getTimezoneOffset() / 60)
const offsetMinutes = date.getTimezoneOffset() % 60
return new Date(date.setHours(-offsetHours, -offsetMinutes, 0)).toISOString().substring(0, 10);
return moment(date).format('YYYY-MM-DD');
}

// check if date can be parsed
Expand Down

0 comments on commit fafd097

Please sign in to comment.