Skip to content

Commit

Permalink
fix: Use date-fns to round dates to nearest minutes
Browse files Browse the repository at this point in the history
  • Loading branch information
paolagres committed Jun 27, 2024
1 parent e3a83a7 commit e6a5173
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"typescript": "^5.0.0"
},
"dependencies": {
"date-fns": "^3.6.0",
"googleapis": "^140.0.0"
},
"version": "1.1.0",
Expand Down
3 changes: 2 additions & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { sheets_v4 } from 'googleapis'
import { SheetCellValue, SheetRow } from './types'
import { roundToNearestMinutes } from 'date-fns'

export function formatRowValues(row: SheetRow, header: string[]): sheets_v4.Schema$CellData[] {
const values: sheets_v4.Schema$CellData[] = []
Expand Down Expand Up @@ -37,5 +38,5 @@ export function getNumberDate(date: Date) {
}

export function getDateFromNumber(numberDate: number) {
return new Date((numberDate - 25569) * (24 * 60 * 60 * 1000))
return roundToNearestMinutes(new Date((numberDate - 25569) * (24 * 60 * 60 * 1000)))
}

0 comments on commit e6a5173

Please sign in to comment.