On Sunday, 17 January 2016 at 18:57:13 UTC, biozic wrote:
On Sunday, 17 January 2016 at 14:43:26 UTC, Borislav Kosharov
wrote:
Seeing that TickDuration is being deprecated and that I should
use Duration instead, I faced a problem. I need to get total
seconds like a float. Using .total!"seconds" returns a long
and if the duration is less than 1 second I get 0. My question
is whats the right way to do it. Because I saw that
TickDuration has a to!("seconds", float) method, but Duration
doesn't have one. I can convert Duration to TickDuration and
call to but seeing that its deprecated makes me think there is
a better way.
Why not just use a smaller granularity for Duration.total and
convert the result?
duration.total!"nsecs" / cast(float) 1e9
Yea I could do that, but its not intuitive to get a total of one
magnitude to just convert it to another. My question is why
doesn't `to!` accept Duration.