From 54d944eded3463f7d6a4dc506fc1885d0cac662d Mon Sep 17 00:00:00 2001 From: Joris Date: Sun, 29 Nov 2015 12:22:22 +0100 Subject: Show days of week in next week notification --- src/Model/Date.hs | 5 +++++ src/Model/Mail.hs | 8 ++++++++ 2 files changed, 13 insertions(+) diff --git a/src/Model/Date.hs b/src/Model/Date.hs index 60108e9..081dccc 100644 --- a/src/Model/Date.hs +++ b/src/Model/Date.hs @@ -5,6 +5,7 @@ module Model.Date , renderDate , getCurrentDate , getNextWeek + , getWeekDay , plusDays , sameDayAndMonth , isBeforeOrEqualDayAndMonth @@ -18,6 +19,7 @@ import Text.Printf (printf) import Data.Time.Clock import Data.Time.Calendar import Data.Time.LocalTime +import Data.Time.Format (formatTime, defaultTimeLocale) import Data.Text (Text) import qualified Data.Text as T import Data.Maybe (isJust) @@ -55,6 +57,9 @@ getNextWeek = do let end = begin `plusDays` 6 return (begin, end) +getWeekDay :: Date -> Text +getWeekDay = T.toLower . T.pack . formatTime defaultTimeLocale "%A" . dateToDay + plusDays :: Date -> Int -> Date plusDays date n = dateFromDay . addDays (toInteger n) . dateToDay $ date diff --git a/src/Model/Mail.hs b/src/Model/Mail.hs index 2af2159..deb720a 100644 --- a/src/Model/Mail.hs +++ b/src/Model/Mail.hs @@ -102,5 +102,13 @@ mailBodyPart event currDate (line, birthdate) = then age currDate birthdate else ageNextWeek currDate birthdate , " years old" + , if event == NextWeek + then + T.concat + [ " on " + , getWeekDay $ (date birthdate) { year = year currDate } + ] + else + "" , if line == SingleLine || line == LastLine then "." else "" ] -- cgit v1.2.3