我如何获得榆木的当前时间? [英] How do I get the current time in Elm?

查看:86
本文介绍了我如何获得榆木的当前时间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行elm-repl来尝试使用该语言。

I'm running elm-repl to play around with the language.

我想看看现在是几点。我该怎么办?当前库似乎无法实现。为什么?

I'd like to see what the current time is. How would I do that? It doesn't appear to be possible with the current library. Why is that?

编辑:我制作了一个软件包来帮助解决这个问题。 http://package.elm-lang.org/packages/z5h/time- app

I made a package to help with this. http://package.elm-lang.org/packages/z5h/time-app

这是在榆树0.15周围提出的-榆树0.17和& 0.18 :请参见如何获取Elm 0.17 / 0.18的当前时间?

This was asked around elm 0.15 - things are different in elm 0.17 & 0.18: see How do I get the current time in Elm 0.17/0.18?

推荐答案

要解决我自己的问题,我创建了一个

因此,更新功能具有签名:

update:action->时间->型号-> (模型,效果动作)

To resolve my own question, I've created a variant of StartApp that includes a timestamp on each action.
So the update function has signature:
update : action -> Time -> model -> (model, Effects action)

要点在这里。
https://gist.github.com/z5h/41ca436679591b6c3e51

这篇关于我如何获得榆木的当前时间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆