diff --git a/CHANGELOG.md b/CHANGELOG.md index 031bab0..b6985d8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ * UI tests replacement with RTL/Jest for view CheckIn. Refs UICHKIN-287. * UI tests replacement with RTL/Jest for Scan component. Refs UICHKIN-289. * Add support for displaySummary token for Staff Slips. Refs UICHKIN-415. +* Remove DST boundary adjustment for item return time. Refs UICHKIN-420. ## [9.0.1] (https://github.com/folio-org/ui-checkin/tree/v9.0.1) (2023-10-23) [Full Changelog](https://github.com/folio-org/ui-checkin/compare/v9.0.0...v9.0.1) diff --git a/src/util.js b/src/util.js index ca72a7d..b64d94d 100644 --- a/src/util.js +++ b/src/util.js @@ -122,21 +122,6 @@ export function buildDateTime(date, time, timezone, now) { const formattedTime = moment(time, ['HH:mm', 'HH:mm a']).format('HH:mm'); const effectiveReturnDate = moment.tz(`${formattedDate}T${formattedTime}`, timezone); - // Check for DST offset. 'time' is passed in adjusted to UTC from whatever time is specified in - // the picker before being converted to a date/time in the local timezone. This works fine if - // there is no difference between the UTC offset *now* and the offset at a date/time specified - // to count items as returned. If there is, due to a change from daylight savings time to standard - // time between the two dates, the recorded time will be an hour off. Unless we do somethng - // like this: - const inDstNow = now.isDST(); - const inDstThen = effectiveReturnDate.isDST(); - - if (inDstNow && !inDstThen) { - effectiveReturnDate.add(1, 'hours'); - } else if (!inDstNow && inDstThen) { - effectiveReturnDate.subtract(1, 'hours'); - } - return effectiveReturnDate.toISOString(); } else { return moment(now).toISOString(); diff --git a/src/util.test.js b/src/util.test.js index f326a33..8b36e84 100644 --- a/src/util.test.js +++ b/src/util.test.js @@ -238,24 +238,31 @@ describe('buildDateTime', () => { expect(v).toMatch('2021-02-14T17:14:00.000Z'); }); - it('given an effective return date before DST, returns an ISO-8601 string', () => { + it('given an effective return date in non-DST, currenty in DST, returns an ISO-8601 string', () => { const d = '2021-03-13'; const t = '12:14:00'; const z = 'America/New_York'; + const now = moment('2021-03-14T12:14:00').tz(z); const v = buildDateTime(d, t, z, now); - expect(v).toMatch('2021-03-13T18:14:00.000Z'); + // America/New_York is offset -4 hrs in DST, -5 hours in non-DST. + // expect to match the non-DST offset of 5 hours in UTC time... + const expected = moment.tz(`${d}T${t}`, 'UTC').add(5, 'hours').toISOString(); + expect(v).toMatch(expected); }); - it('given an effective return date after DST, returns an ISO-8601 string', () => { + it('given an effective return date in DST, currently non-DST, returns an ISO-8601 string', () => { const d = '2021-11-06'; const t = '12:14:00'; const z = 'America/New_York'; const now = moment('2021-11-07T12:14:00').tz(z); const v = buildDateTime(d, t, z, now); - expect(v).toMatch('2021-11-06T15:14:00.000Z'); + // America/New_York is offset -4 hrs in DST, -5 hours in non-DST. + // expect to match the DST offset of 4 hours in UTC time... + const expected = moment.tz(`${d}T${t}`, 'UTC').add(4, 'hours').toISOString(); + expect(v).toMatch(expected); }); });