aboutsummaryrefslogtreecommitdiff
path: root/src/client/View/Date.elm
blob: 35806ba11075514486b47383f011523a164aee33 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
module View.Date exposing
  ( shortView
  , longView
  , monthView
  )

import Date exposing (..)
import Date.Extra.Core as Date
import String

import Model.Translations exposing (..)

shortView : Date -> Translations -> String
shortView date translations =
  let params =
        [ String.pad 2 '0' (toString (Date.day date))
        , String.pad 2 '0' (toString (Date.monthToInt (Date.month date)))
        , toString (Date.year date)
        ]
  in  getParamMessage params translations "ShortDate"

longView : Date -> Translations -> String
longView date translations =
  let params =
        [ toString (Date.day date)
        , (getMessage translations (getMonthKey (Date.month date)))
        , toString (Date.year date)
        ]
  in  getParamMessage params translations "LongDate"

monthView : Translations -> Month -> String
monthView translations month = getMessage translations (getMonthKey month)

getMonthKey : Month -> String
getMonthKey month =
  case month of
    Jan -> "January"
    Feb -> "February"
    Mar -> "March"
    Apr -> "April"
    May -> "May"
    Jun -> "June"
    Jul -> "July"
    Aug -> "August"
    Sep -> "September"
    Oct -> "October"
    Nov -> "November"
    Dec -> "December"