diff options
author | Joris | 2015-11-21 17:32:28 +0100 |
---|---|---|
committer | Joris | 2015-11-21 17:32:28 +0100 |
commit | 6850159bf998a209ad7b6d7103d113a54659937e (patch) | |
tree | b2aadbf5fc516927a7c527f995fb829cffc551d4 /src/Date.hs | |
parent | 94da91e1db4a5c130aa50579473e6a0a6b7a7958 (diff) |
Add filter birthday between function
Diffstat (limited to 'src/Date.hs')
-rw-r--r-- | src/Date.hs | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/Date.hs b/src/Date.hs index 8ab9fd2..63830d3 100644 --- a/src/Date.hs +++ b/src/Date.hs @@ -2,6 +2,8 @@ module Date ( Date(..) , getCurrentDate , sameDayAndMonth + , isBeforeOrEqualDayAndMonth + , isAfterOrEqualDayAndMonth , yearsGap ) where @@ -29,5 +31,21 @@ sameDayAndMonth d1 d2 = && month d1 == month d2 ) +isBeforeOrEqualDayAndMonth :: Date -> Date -> Bool +isBeforeOrEqualDayAndMonth d1 d2 = + ( month d1 < month d2 + || ( month d1 == month d2 + && day d1 <= day d2 + ) + ) + +isAfterOrEqualDayAndMonth :: Date -> Date -> Bool +isAfterOrEqualDayAndMonth d1 d2 = + ( month d1 > month d2 + || ( month d1 == month d2 + && day d1 >= day d2 + ) + ) + yearsGap :: Date -> Date -> Int yearsGap d1 d2 = abs (year d2 - year d1) |