'use strict'; const assert = require('assert'); const appDateTime = require('../helpers/application_datetime'); function iso(date) { return date.toISOString(); } function run() { const brisbaneOffset = appDateTime.getUtcOffsetMinutesFromLocation(-27.4698, 153.0251, '2025-05-22'); const chicagoOffset = appDateTime.getUtcOffsetMinutesFromLocation(41.8781, -87.6298, '2025-05-22'); assert.strictEqual(brisbaneOffset, 600, 'Brisbane should be UTC+10 in May'); assert.strictEqual(chicagoOffset, -300, 'Chicago should be UTC-5 in May'); assert.strictEqual( iso(appDateTime.toUtcDateFromAppDateTime('20250522T000000', 600)), '2025-05-22T00:00:00.000Z', 'UTC+10 hybrid time should stay on the same UTC day when UTC time-of-day is midnight' ); assert.strictEqual( iso(appDateTime.toUtcDateFromAppDateTime('20250522T220000', 600)), '2025-05-21T22:00:00.000Z', 'UTC+10 hybrid time should roll back one UTC day when the local wall clock crosses midnight' ); assert.strictEqual( iso(appDateTime.toUtcDateFromAppDateTime('20250522T150000', -300)), '2025-05-22T15:00:00.000Z', 'UTC-5 hybrid time should preserve the UTC day for afternoon records' ); const isoUtc = '2025-05-22T10:15:30.000Z'; assert.strictEqual( iso(appDateTime.toUtcDateFromAppDateTime(isoUtc, 600)), isoUtc, 'ISO UTC inputs should be returned unchanged' ); const meta = appDateTime.buildApplicationDateFields({ startDateTime: '20250522T000000', endDateTime: '20250522T220000', latitude: -27.4698, longitude: 153.0251 }); assert.strictEqual(meta.utcOffset, 600, 'Build helper should return the location-based offset'); assert.strictEqual(iso(meta.startDateTimeUTC), '2025-05-22T00:00:00.000Z'); assert.strictEqual(iso(meta.endDateTimeUTC), '2025-05-21T22:00:00.000Z'); console.log('✅ application datetime helper tests passed'); } run();