Get current date and time with std.datetime

Jonathan M Davis jmdavisProg at gmx.com
Mon Oct 24 08:28:23 PDT 2011


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


More information about the Digitalmars-d-learn mailing list