Get current date and time with std.datetime
Luke Picardo via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Thu Jun 30 14:18:22 PDT 2016
On Monday, 24 October 2011 at 15:29:41 UTC, Jonathan M Davis
wrote:
> On Friday, October 07, 2011 19:58:12 Joel Christensen wrote:
>> > http://d-programming-language.org/intro-to-datetime.html
>>
>> Thanks Jonathan, that helped I think, (haven't read it all,
>> though). But I've got errors with some of the date times not
>> being able to change them with int's values.
>>
>> task.d(44): Error: function std.datetime.DateTime.month ()
>> const is not
>> callable using argument types (int)
>> task.d(44): Error: cannot implicitly convert expression
>> (month0) of type
>> int to Month
>
> Month is an enum. So, any function taking a month must take an
> enum value, not an integer. e.g. Month.jan, Month.feb,
> Month.mar, etc. If you want to pass it an integral value, you
> have to cast. e.g. cast(Month)1, cast(Month)2, cast(Month)3,
> etc.
>
> - Jonathan M Davis
Why is it so hard to simply get the current date and time
formatted properly in a string?
There are no examples of this in your documentation yet this is
probably one of the most used cases.
More information about the Digitalmars-d-learn
mailing list