@unikue/ts-lang-utils
    Preparing search index...

    Function compareDate

    • Returns 1 if source greater than target, -1 if source less than target, 0 if equals

      Parameters

      • Optionalsource: string | Date | null

        The first date to compare

      • Optionaltarget: string | Date | null

        The second date to compare

      • nullGreater: boolean = false

        Whether a nil (undefined or null) value is considered greater than another non-nil value

      Returns number

      1 if source greater than target, -1 if source less than target, 0 if equals

      David Hsing

      compareDate(new Date('2023-01-02'), new Date('2023-01-01'));    // 1
      compareDate(new Date('2023-01-01'), new Date('2023-01-02')); // -1
      compareDate(new Date('2023-01-01'), '2023-01-01'); // 0
      compareDate(undefined, null); // 0
      compareDate(undefined, new Date(), true); // 1
      compareDate(undefined, new Date(), false); // -1