Skip to content

Commit

Permalink
refactor(domain): remove obsolete date function
Browse files Browse the repository at this point in the history
  • Loading branch information
DmitriySevkovych committed Aug 13, 2024
1 parent e9c8e17 commit a624796
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 15 deletions.
10 changes: 0 additions & 10 deletions packages/domain-model/src/models/dates.model.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
getNextDay,
getNextWorkday,
getNumberOfDaysInMonth,
timestampFromString,
} from './dates.model'

/*
Expand Down Expand Up @@ -42,15 +41,6 @@ describe('Tests for dealing with dates', () => {
}
)

it('timestampFromString should convert to a numeric timestamp', () => {
// Arrange
const dateString = '2011-01-02'
// Act
const timestamp = timestampFromString(dateString)
// Assert
expect(typeof timestamp).toBe('number')
})

it.each`
dateString
${'1999-08-02'}
Expand Down
8 changes: 3 additions & 5 deletions packages/domain-model/src/models/dates.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,6 @@ export const formatDateToWords = (
return dateString
}

export const timestampFromString = (dateString: string): number => {
return Date.parse(dateString)
}

export const dateFromString = (dateString: string): Date => {
// Try to deserialize SQL date string
let date = DateTime.fromSQL(dateString, { zone: 'utc' })
Expand All @@ -88,7 +84,9 @@ export const dateFromString = (dateString: string): Date => {
}

if (!date.isValid) {
console.error({ dateString, date })
// console.error({ dateString, date })
// TODO temporary hack. Needs better fallback
date = DateTime.fromJSDate(new Date(dateString))
}

return date.toJSDate()
Expand Down

0 comments on commit a624796

Please sign in to comment.