diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2015-03-31 07:11:03 +0900 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2015-03-31 07:11:03 +0900 |
commit | e5ea1006d9f5e5202b058c8e342d186df2db07ca (patch) | |
tree | 4788aeacc9849c19f1d507b9f0e81719dfc66b6d | |
parent | b55bf2acfafa913a4da36e90569577bbbccee4fc (diff) | |
download | srem-e5ea1006d9f5e5202b058c8e342d186df2db07ca.tar.gz |
event cache file names based on local time
-rw-r--r-- | src/Utility/EventCache.hs | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/Utility/EventCache.hs b/src/Utility/EventCache.hs index a962286..efda675 100644 --- a/src/Utility/EventCache.hs +++ b/src/Utility/EventCache.hs @@ -35,7 +35,7 @@ import qualified Control.SremConfig as SremConfig import Data.List.Split (splitOn, splitOneOf) import Data.Maybe.Read import Data.Time.Calendar -import Data.Time.Clock +import Data.Time.LocalTime import System.Directory (doesFileExist, getDirectoryContents, removeFile) import System.FilePath ((</>)) @@ -51,7 +51,7 @@ purgeOldEventCaches = do files <- (SremConfig.getCacheDirectory >>= getDirectoryContents) `catch` ((\_ -> return []) :: IOException -> IO [FilePath]) - today <- utctDay <$> getCurrentTime + today <- localDay . zonedTimeToLocalTime <$> getZonedTime forM_ files $ \file -> when (fileIsOldCache today file) $ removeFile file @@ -118,7 +118,8 @@ makeEventCSV r = (show . getReminderHour $ r) ++ "," ++ ++ getReminderText r todaysCacheFileDateString :: IO String -todaysCacheFileDateString = showGregorian . utctDay <$> getCurrentTime +todaysCacheFileDateString = showGregorian . localDay . zonedTimeToLocalTime + <$> getZonedTime fileIsOldCache :: Day -> FilePath -> Bool fileIsOldCache today file = length splitFile == 3 |