module Villefort.Time where import Data.List.Split as S import Data.Time import Data.Time.Calendar.OrdinalDate data D = D { year :: Integer, month :: Int, day :: Int} deriving (Show) fromZonedTimeToDay :: String -> Day fromZonedTimeToDay x = fromGregorian (year up) (month up ) (day up) where up = unpackStringToDate x unpackStringToDate x = D (read (nums !! 0) :: Integer) (read (nums !! 1) :: Int) (read (nums !! 2) :: Int) where nums = S.splitOn "-" $ take 10 x daysUntil date = do c <- getCurrentTime let (y,m,d) = toGregorian $ utctDay c let split = S.splitOn "-" date current <- fromZonedTimeToDay <$> show <$> getZonedTime let due = fromGregorian (read (split !! 0) :: Integer) (read (split !! 1) :: Int) (read (split !! 2) :: Int) return $ (diffDays due current) getDate :: IO Day getDate = fromZonedTimeToDay <$> show <$> getZonedTime getDateD = unpackStringToDate <$> show <$> getZonedTime getDay :: IO Int getDay = do z <- getDate return $ snd $mondayStartWeek z