lt, eq, gt methods for date

Signed-off-by: Skyball2000 <thomas3654william@gmail.com>
main
Yan Wittmann 2022-11-08 11:43:25 +01:00 committed by Skyball2000
parent 48c254acaa
commit b575fc1b50
2 changed files with 12 additions and 40 deletions

View File

@ -23,11 +23,20 @@ day (a, _, _) = a
-- 1 Punkt: -- 1 Punkt:
lt : Date -> Date -> Bool lt : Date -> Date -> Bool
lt date1 date2 = False lt date1 date2 =
let (d1, m1, y1) = date1
(d2, m2, y2) = date2
in y1 < y2 || (y1 == y2 && (m1 < m2 || (m1 == m2 && d1 < d2)))
eq : Date -> Date -> Bool eq : Date -> Date -> Bool
eq date1 date2 = False eq date1 date2 =
let (d1, m1, y1) = date1
(d2, m2, y2) = date2
in y1 == y2 && m1 == m2 && d1 == d2
gt : Date -> Date -> Bool gt : Date -> Date -> Bool
gt date1 date2 = False gt date1 date2 =
let (d1, m1, y1) = date1
(d2, m2, y2) = date2
in y1 > y2 || (y1 == y2 && (m1 > m2 || (m1 == m2 && d1 > d2)))
-- 1 Punkt: -- 1 Punkt:
toString : Date -> String toString : Date -> String

View File

@ -7,43 +7,6 @@ import Test exposing (..)
import Pflichtuebung_01.Date exposing (..) import Pflichtuebung_01.Date exposing (..)
--type alias Day =
-- Int
--
--
--type alias Month =
-- Int
--
--
--type alias Year =
-- Int
--
--
--type alias Date =
-- ( Day, Month, Year )
--
---- 1 Punkt:
--year : Date -> Year
----year (a, b, c) = c
--month : Date -> Month
----month (a,b,c) = b
--day : Date -> Day
----day (a,b , c) = a
--
--lt : Date -> Date -> Bool
--eq : Date -> Date -> Bool
--gt : Date -> Date -> Bool
--
--toString : Date -> String
--
--next : Date -> Date
--
--prev : Date -> Date
--
--leapyear : Year -> Bool
--
--sub : Date -> Date -> Int
testYear : Test testYear : Test
testYear = testYear =
describe "year method test" describe "year method test"