Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
GitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
time: add Duration-conversion functions Milliseconds() and Microseconds() #28564
I propose adding these two
func (d Duration) Milliseconds() float64 func (d Duration) Microseconds() float64
(these were already proposed in #5491 as
Here's a map of
If these are added, it might lead to suggestions for other similarly
What version of Go are you using (
@ianlancetaylor those were for different functions, but I mentioned them above too. The idea of a library to measure popularity is interesting, but I don't see how people would know it exists unless they come across these GH issues (which probably explains the low Star count on https://github.com/ulikunitz/unixtime).
Not that I know of; my main motivation was to lay out a case for why these should exist.
I'm sympathetic, since it's so easy to mistype the division (e.g. you have to remember NOT to type t.Nanoseconds() / 1000 for milliseconds).
The way you get float would be t.Seconds() * 1000 which is easy to remember.
The return values are integers, as opposed to floats, since the fractionals can be derived from multiplying t.Seconds(). Fixes golang#28564