CalOohPay API Documentation - v2.1.0
    Preparing search index...

    Function coerceUntil

    • 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.

      Parameters

      • value: string

        The date string to coerce (ISO format or YYYY-MM-DD)

      Returns string

      ISO string representing the last millisecond of the specified date

      If the date string cannot be parsed as a valid ISO 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.

      • Parses input as ISO string
      • Sets time to 23:59:59.999 (end of day)
      • Returns full ISO format with timezone
      • Throws error if parsing fails (fail-fast approach)

      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).