1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-08-08 15:05:22 +02:00

normalize all DateTime calls to utc in test

This commit is contained in:
Karan Handa 2024-01-19 17:55:40 +05:30
parent b00f97d033
commit 538583d811
2 changed files with 11 additions and 11 deletions

View file

@ -35,17 +35,17 @@ describe('calculateTimeSeriesInterval', () => {
describe('converts between years and ages', () => {
it.each`
dateOfBirth | currentAge
${'1995-02-20'} | ${27}
${new Date('Feb 20 1995')} | ${27}
${DateTime.fromISO('1995-02-20')} | ${27}
${null} | ${null}
${undefined} | ${null}
${'2022-10-15'} | ${0}
${'2021-10-12'} | ${1}
${'2021-10-18'} | ${0}
dateOfBirth | currentAge
${'1995-02-20'} | ${27}
${new Date('Feb 20 1995')} | ${27}
${DateTime.fromISO('1995-02-20', { zone: 'utc' })} | ${27}
${null} | ${null}
${undefined} | ${null}
${'2022-10-15'} | ${0}
${'2021-10-12'} | ${1}
${'2021-10-18'} | ${0}
`(`dob $dateOfBirth is $currentAge years old today`, ({ dateOfBirth, currentAge }) => {
const now = DateTime.fromISO('2022-10-15')
const now = DateTime.fromISO('2022-10-15', { zone: 'utc' })
expect(dobToAge(dateOfBirth, now)).toBe(currentAge)
})

View file

@ -132,7 +132,7 @@ export function dobToAge(dob: string | Date | DateTime | null | undefined, now =
? DateTime.fromJSDate(dob, { zone: 'utc' })
: dob
return Math.max(Math.floor(now.diff(normalizedDate, 'years').years), 0)
return Math.floor(now.diff(normalizedDate, 'years').years)
}
// We allow a maximum of 30 years of history for performance reasons (hypertable chunking)