文書の過去の版を表示しています。
Elmでtime
https://qiita.com/ababup1192/items/803bd2e66461c70bf7e7
@ababup1192
2019年01月06日に更新
Elm3(予備) Advent Calendar 201815日目
Elm TDDしながらelm/timeで日付の変換をする
http://i-doctor.sakura.ne.jp/font/?p=37690
ElmとFirebaseでチャットアプリを写経してみる(1)実行してみる
2019年5月10日
http://i-doctor.sakura.ne.jp/font/?p=38884
ElmとFirebaseでチャットアプリを写経してみる(2)複数ファイルを1個のファイルにする
2019年6月13日2019年6月16日
elmでtime関連リンク
https://qiita.com/miyamo_madoka/items/ae83fe3a43eac432434e
@miyamo_madoka
2019年04月16日に更新
Elmで日付を扱う0.19編
上記によると、日本語のサイトなら、以下の方法で十分かも、、、
https://package.elm-lang.org/packages/justinmimbs/timezone-data/latest/
elm install justinmimbs/timezone-data
してから、
import Time import TimeZone exposing (asia__tokyo) zone : Time.Zone zone = asia__tokyo()
elmで月monthを表示
月はTime.Monthとしてカスタムタイプで定義されているため、表示できない!
かなり面倒だが、自分で関数を作らないといけない。
→あった!感謝!
https://github.com/ababup1192/elm-firebase-chat/blob/master/src/Main.elm
import Time exposing (Month(..), Posix, Weekday(..), Zone) | |
-- --------------------------- | |
-- TIME Util | |
-- --------------------------- | |
toDate : Zone -> Posix -> String | |
toDate zone time = | |
let | |
padZero2 = | |
String.padLeft 2 '0' | |
month = | |
Time.toMonth zone time |> toMonthNumber | |
day = | |
Time.toDay zone time |> String.fromInt | |
year = | |
Time.toYear zone time |> String.fromInt | |
hour = | |
Time.toHour zone time |> String.fromInt |> padZero2 | |
minutes = | |
Time.toMinute zone time |> String.fromInt |> padZero2 | |
week = | |
Time.toWeekday zone time |> toJapaneseWeekday | |
in | |
year ++ "年" ++ month ++ "月" ++ day ++ "日 " ++ hour ++ ":" ++ minutes ++ " " ++ week ++ "曜日" | |
toMonthNumber : Time.Month -> String | |
toMonthNumber 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" | |
toJapaneseWeekday : Weekday -> String | |
toJapaneseWeekday weekday = | |
case weekday of | |
Mon -> | |
"月" | |
Tue -> | |
"火" | |
Wed -> | |
"水" | |
Thu -> | |
"木" | |
Fri -> | |
"金" | |
Sat -> | |
"土" | |
Sun -> | |
"日" | |
リンク