如何从UTCTime获取秒和毫秒部分? [英] How to get the seconds and millisecond component from UTCTime?

查看:178
本文介绍了如何从UTCTime获取秒和毫秒部分?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

换句话说,我正在寻找Python的 datetime.utcnow()

In other words, I'm looking for the equivalent of Python's datetime.utcnow().

我也可以使用包含年,月等的n元组,​​直到毫秒(或微秒)。

I'm also fine with a n-tuple containing years, months and so on, up until milliseconds (or microseconds).

我曾经考虑过使用 show 然后解析 String 值,但我相信还有一些更方便的方法。

I had thought of using show and then parsing the String value, but I believe there's something more convenient.

推荐答案

重新解析字符串是非常不礼貌的,您当然不想要。

Re-parsing a string is very un-Haskellish, you certainly don't want that.

我会使用 Data.Time.LocalTime

todSec . localTimeOfDay . utcToLocalTime utc  ::  UTCTime -> Data.Fixed.Pico

为您提供秒级的皮秒分辨率。

that gives you seconds in picosecond-resolution.

这篇关于如何从UTCTime获取秒和毫秒部分?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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