haskell / time

A time library
http://hackage.haskell.org/package/time
Other
118 stars 78 forks source link

converting picoseconds to micro and milliseconds #236

Closed DeamonDev closed 1 year ago

DeamonDev commented 1 year ago

There is only one function which converts DiffTime into numeric value which is diffTimeToPicoseconds. I don't see any reason to distinguish picoseconds from the other time measurement units. Lot of other libs in the Haskell's ecosystem accepts microseconds (e.g. threadDelay from Control.Concurrent). Of course it is very easy to do the conversions on its own, but I think we should pull this out in front of the parentheses (and it is the right place to do so). My proposal is to add two other conversions which are diffTimeToMicroseconds and diffTimeToMilliseconds.

AshleyYakeley commented 1 year ago

Integer picoseconds is the internal representation of the DiffTime type, that's the only reason for diffTimeToPicoseconds. Milliseconds and microseconds would not be integers.

DeamonDev commented 1 year ago

Okay, good point. But what about taking a floor function over the resulting fractional?

@edit The quot function is taking care of that.

AshleyYakeley commented 1 year ago

I would prefer to avoid the proliferation of trivial functions.