The date string to coerce (ISO format or YYYY-MM-DD)
ISO string representing the last millisecond of the specified date
This function is used in the CLI to normalize the --until parameter,
ensuring that calculations include all shifts ending on the specified date,
even those ending at 23:59.
Using end-of-day ensures that overnight shifts ending early on the final day are still included in the calculation period.
coerceUntil('2024-08-31');
// Returns: '2024-08-31T23:59:59.999+01:00' (or relevant timezone)
coerceUntil('2024-08-31T10:00:00Z');
// Returns: '2024-08-31T23:59:59.999Z'
coerceUntil('not-a-date');
// Throws: Error: Invalid date format: not-a-date. Expected ISO format (YYYY-MM-DD or YYYY-MM-DDTHH:mm:ssZ).
Coerces a date string to the end of day (23:59:59.999) and returns ISO string.
Takes a date string and normalizes it to the very last millisecond of that day. Ensures that date range queries include all events occurring during the specified end date, up to but not including midnight of the next day.