Skip to content

Commit

Permalink
fix: removed unnecessary offset in daysBetween
Browse files Browse the repository at this point in the history
  • Loading branch information
dereekb committed Jul 15, 2022
1 parent 8d32705 commit 670a2de
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/dateutil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,12 @@ export const tzOffset = function (date: Date) {
export const daysBetween = function (date1: Date, date2: Date) {
// The number of milliseconds in one day
// Convert both dates to milliseconds
const date1ms = date1.getTime() - tzOffset(date1)
const date2ms = date2.getTime() - tzOffset(date2)
const date1ms = date1.getTime()
const date2ms = date2.getTime()

// Calculate the difference in milliseconds
const differencems = date1ms - date2ms

// Convert back to days and return
return Math.round(differencems / ONE_DAY)
}
Expand Down

0 comments on commit 670a2de

Please sign in to comment.