aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJoris2015-11-29 12:22:22 +0100
committerJoris2015-11-29 12:22:22 +0100
commit54d944eded3463f7d6a4dc506fc1885d0cac662d (patch)
tree24ce7cf6892fea56a147275eb024759fec040eff /src
parenta9bc46efe3624344573f96fafa8af194016183a2 (diff)
Show days of week in next week notification
Diffstat (limited to 'src')
-rw-r--r--src/Model/Date.hs5
-rw-r--r--src/Model/Mail.hs8
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 ""
]