diff options
Diffstat (limited to 'src/client/elm/Utils')
-rw-r--r-- | src/client/elm/Utils/Date.elm | 39 | ||||
-rw-r--r-- | src/client/elm/Utils/Http.elm | 11 |
2 files changed, 48 insertions, 2 deletions
diff --git a/src/client/elm/Utils/Date.elm b/src/client/elm/Utils/Date.elm new file mode 100644 index 0000000..7a245bc --- /dev/null +++ b/src/client/elm/Utils/Date.elm @@ -0,0 +1,39 @@ +module Utils.Date + ( monthToNum + , numToMonth + ) where + +import Date exposing (..) + +monthToNum : Month -> Int +monthToNum month = + case month of + Jan -> 1 + Feb -> 2 + Mar -> 3 + Apr -> 4 + May -> 5 + Jun -> 6 + Jul -> 7 + Aug -> 8 + Sep -> 9 + Oct -> 10 + Nov -> 11 + Dec -> 12 + +numToMonth : Int -> Month +numToMonth n = + case n of + 1 -> Jan + 2 -> Feb + 3 -> Mar + 4 -> Apr + 5 -> May + 6 -> Jun + 7 -> Jul + 8 -> Aug + 9 -> Sep + 10 -> Oct + 11 -> Nov + 12 -> Dec + _ -> Jan diff --git a/src/client/elm/Utils/Http.elm b/src/client/elm/Utils/Http.elm index bd6e2ac..b394af4 100644 --- a/src/client/elm/Utils/Http.elm +++ b/src/client/elm/Utils/Http.elm @@ -1,5 +1,6 @@ module Utils.Http ( post + , delete , decodeHttpValue , errorKey ) where @@ -9,8 +10,14 @@ import Task exposing (..) import Json.Decode as Json exposing (Decoder) post : String -> Task Error Value -post url = - { verb = "POST" +post = request "POST" + +delete : String -> Task Error Value +delete = request "DELETE" + +request : String -> String -> Task Error Value +request method url = + { verb = method , headers = [] , url = url , body = empty |