Post-Cancellation, Pre-Nisei Netrunner Rotation
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

25 lines
648B

  1. module Timestamp where
  2. data Timestamp = Ts Integer Integer Integer deriving Show
  3. isPreviewSeason :: Timestamp -> Bool
  4. isPreviewSeason (Ts x _ _) = x >= 20
  5. inFuture :: Timestamp -> Timestamp -> Bool
  6. inFuture (Ts d1 m1 y1) (Ts d2 m2 y2)
  7. | y1 /= y2 = y1 > y2
  8. | m1 /= m2 = m1 > m2
  9. | d1 /= d2 = d1 > d2
  10. | otherwise = False
  11. monthsSince :: Timestamp -> Timestamp -> Integer
  12. monthsSince (Ts d1 m1 y1) (Ts d2 m2 y2)
  13. | t1 `inFuture` t2 = (12 * (y1 - y2)) + (m1 - m2)
  14. | otherwise = 0
  15. where
  16. t1 = Ts d1 m1 y1
  17. t2 = Ts d2 m2 y2
  18. toTS :: (Integer, Integer, Integer) -> Timestamp
  19. toTS (y,m,d) = Ts d m y