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

    Function coerceSince

    • Coerces a date string to the start of day (midnight) and returns ISO string with timezone.

      Takes a date string (typically YYYY-MM-DD or ISO format) and normalizes it to the beginning of that day (00:00:00.000). Useful for ensuring date range queries start at the very beginning of the specified date.

      Parameters

      • value: string

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

      Returns string

      ISO string representing midnight on 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 --since parameter, ensuring that calculations start at the exact beginning of the day in the schedule's timezone.

      • Parses input as ISO string
      • Sets time to 00:00:00.000 (start of day)
      • Returns full ISO format with timezone
      • Throws error if parsing fails (fail-fast approach)
      coerceSince('2024-08-01');
      // Returns: '2024-08-01T00:00:00.000+01:00' (or relevant timezone)

      coerceSince('2024-08-01T14:30:00Z');
      // Returns: '2024-08-01T00:00:00.000Z'

      coerceSince('invalid-date');
      // Throws: Error: Invalid date format: invalid-date. Expected ISO format (YYYY-MM-DD or YYYY-MM-DDTHH:mm:ssZ).