Date Comparison ; - - - The Data Definition - - - (define-struct date [year month day hour minute second]) ; A Date is a structure: ; (make-date Nat Nat Nat Nat Nat Nat) ; interpretation. records six pieces of information: ; the date's year, month (between 1 and 12 inclusive), ; day (between 1 and 31), hour (between 0 ; and 23), minute (between 0 and 59), and ; second (also between 0 and 59). ; - - - Signature and Purpose - - - ; older: Date Date -> Boolean ; comparator on dates ; - - - Tests - - - (older (make-date 2005 02 23 12 12 12) (make-date 2018 04 20 02 25 06)) ; => #true (older (make-date 2005 01 23 12 12 12) (make-date 2005 04 20 02 25 06)) ; => #true (older (make-date 2005 04 19 12 12 12) (make-date 2005 04 20 02 25 06)) ; => #true (older (make-date 2005 04 19 00 12 12) (make-date 2005 04 19 02 25 06)) ; => #true (older (make-date 2005 04 19 00 12 12) (make-date 2005 04 19 00 25 06)) ; => #true (older (make-date 2005 04 19 00 12 03) (make-date 2005 04 19 00 12 06)) ; => #true (older (make-date 2005 04 19 00 12 09) (make-date 2005 04 19 00 12 06)) ; => #false (older (make-date 2018 04 20 02 25 06) (make-date 2005 02 23 12 12 12)) ; => #false (older (make-date 2005 04 20 02 25 06) (make-date 2005 01 23 12 12 12)) ; => #false (older (make-date 2005 04 20 02 25 06) (make-date 2005 04 19 12 12 12)) ; => #false (older (make-date 2005 04 19 02 25 06) (make-date 2005 04 19 00 12 12)) ; => #false (older (make-date 2005 04 19 00 25 06) (make-date 2005 04 19 00 12 12)) ; => #false (older (make-date 2005 04 19 00 12 06) (make-date 2005 04 19 00 25 06)) ; => #true (older (make-date 2005 04 19 01 01 01) (make-date 2005 04 19 01 01 01)) ; => #false (older (make-date 2005 04 19 01 01 01) (make-date 2004 04 20 01 01 01)) ; => #false ; - - - Function - - - (define (older d1 d2) (cond [(> (date-year d2) (date-year d1)) #true ] [(< (date-year d2) (date-year d1)) #false] [(> (date-month d2) (date-month d1)) #true ] [(< (date-month d2) (date-month d1)) #false] [(> (date-day d2) (date-day d1)) #true ] [(< (date-day d2) (date-day d1)) #false] [(> (date-hour d2) (date-hour d1)) #true ] [(< (date-hour d2) (date-hour d1)) #false] [(> (date-minute d2) (date-minute d1)) #true ] [(< (date-minute d2) (date-minute d1)) #false] [(> (date-second d2) (date-second d1)) #true ] [(< (date-second d2) (date-second d1)) #false] [else #false]))