Duration.toTimeVal ? (following deprecation from 2.066)

Timothee Cour via Digitalmars-d digitalmars-d at puremagic.com
Sun Aug 10 23:01:24 PDT 2014


Thanks; shouldn't this be a function ?
we have SysTime.toTimeVal, why not Duration.toTimeVal?


On Sun, Aug 10, 2014 at 8:40 PM, Jonathan M Davis via Digitalmars-d <
digitalmars-d at puremagic.com> wrote:

> On Monday, 11 August 2014 at 02:46:11 UTC, Timothee Cour via Digitalmars-d
> wrote:
>
>> On Sun, Aug 10, 2014 at 7:21 PM, Timothee Cour <thelastmammoth at gmail.com>
>> wrote:
>>
>>  This used to work prior to 2.066 (rc):
>>> Duration t;
>>> auto tv=timeval(t.total!"seconds",t.fracSec.usecs);
>>> now it works but with:
>>> Deprecation: function core.time.Duration.fracSec is deprecated - Please
>>> use split instead.
>>>
>>> I see there's a SysTime.toTimeVal but there's no Duration.toTimeVal.
>>> Shouldn't there be?
>>> What would be the new recommended implementation?
>>> Also, I think deprecation messages could be more precise, telling exactly
>>> how to make the change instead of telling you the function name.
>>>
>>>
>>>  is this correct?
>>     int secs,usecs;
>>     timeout.split!("seconds","usecs")(secs,usecs);
>>     auto tv=timeval(secs,usecs);
>> specifically, I'm not sure about the type 'int'.
>>
>
> Technically, timeval is
>
> struct timeval
> {
>     time_t      tv_sec;
>     suseconds_t tv_usec;
> }
>
> so tv_sec is 64-bits on a 64-bit system, though you'd probably get away
> with using an int. Regardless, I'd suggest doing this:
>
> timeval tv;
> timeout.split!("seconds, "usecs")(tv.tv_sec, tv.tv_usec);
>
> since then you don't have to care what integral type they are.
>
> - Jonathan M Davis
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20140810/80812765/attachment.html>


More information about the Digitalmars-d mailing list