time icon indicating copy to clipboard operation
time copied to clipboard

Keep Pico unit explicit when converting to and from DiffTime

Open VictorCMiraldo opened this issue 1 year ago • 4 comments

(Re-submitting a patched #237, inlining the description for convenience)

The conversion of picoseconds to and from DiffTime doesn't keep the unit explicit. Which can be confusing and is not homogeneous with the same conversion, but to and from NominalDiffTime. This is a very simple PR to make the API a little more consistent.

@AshleyYakeley, if this is still not correct, please let me know, I'm happy to fix it :)

VictorCMiraldo avatar Apr 20 '23 08:04 VictorCMiraldo

No reason to get rid of picosecondsToDiffTime, diffTimeToPicoseconds, is there?

AshleyYakeley avatar Apr 23 '23 08:04 AshleyYakeley

The reason was to homogenize the interface of DiffTime and NominalDiffTime, providing the same functions with similar names.

That being said, if we rather not remove somethint but still want a homogeneous API, we could instead add nominalDiffTimeToPicoseconds and picosecondsToNominalDiffTime.

What do you think?

VictorCMiraldo avatar Apr 23 '23 17:04 VictorCMiraldo

So this is a breaking change in any case and I would prefer to break as little as possible. The whole point of picoseconds is that is the underlying Integer type, that, for example, the Enum instance is based on.

AshleyYakeley avatar Apr 23 '23 22:04 AshleyYakeley

That's fair! I'll bring them back later today or tomorrow!

VictorCMiraldo avatar Apr 25 '23 06:04 VictorCMiraldo