diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Model/Date.hs | 5 | ||||
-rw-r--r-- | src/Model/Mail.hs | 8 |
2 files changed, 13 insertions, 0 deletions
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 "" ] |