How to add time to Clock.currTime
JohnnyK
johnnykinsey at comcast.net
Mon Oct 7 06:26:45 PDT 2013
On Saturday, 5 October 2013 at 02:42:49 UTC, Jonathan M Davis
wrote:
> On Saturday, October 05, 2013 03:31:33 JohnnyK wrote:
>> Wow I appreciate the quick response. Ok I have seen this
>> before.
>> What is the dur? Where is dur defined? Also I am confused how
>> 300.seconds would work. How can a literal number have
>> properties?
>
> dur is in core.time as are the aliases for each of the units:
>
> http://dlang.org/phobos/core_time.html#dur
>
> 300.seconds works thanks to UFCS (Universal Function Call
> Syntax). Any time
> that the compiler sees
>
> x.foo(args);
>
> and foo is not a member function of x, it converts it to
>
> foo(x, args);
>
> So, if there's a free function with that name which will work
> with those
> arguments, then it will be called (otherwise, you'll get an
> error, because
> there is no matching function). The parens can be dropped on
> 300.seconds,
> because the parens are optional on function calls that take no
> arguments.
> seconds is not actually a property function (it's an alias for
> dur!"seconds,
> which is not a property function either), but the fact that the
> parens are
> optional makes it so that you can use it with the same syntax
> that would be
> used for a getter property.
>
> If you want an overview of std.datetime and the time stuff in
> Phobos, I suggest
> that you read
>
> http://dlang.org/intro-to-datetime.html
>
> - Jonathan M Davis
I appreciate everyone's responses and yes Jonathan that article
did help. I know I looked under the article section but I must
have overlooked this article.
More information about the Digitalmars-d-learn
mailing list