www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Get current date and time with std.datetime

reply Joel Christensen <joelcnz gmail.com> writes:
Hi,

I have a program that uses the old time stuff before the module 
std.datetime. I have a DateTime object, but I can't seem to set its 
properties to the current time.

Some thing like:
DateTime dateTime;
dateTime = getCurrentDateTime();

-JoelCNZ
Oct 06 2011
next sibling parent reply Jonathan M Davis <jmdavisProg gmx.com> writes:
On Friday, October 07, 2011 19:08:33 Joel Christensen wrote:
 Hi,
 
 I have a program that uses the old time stuff before the module
 std.datetime. I have a DateTime object, but I can't seem to set its
 properties to the current time.
 
 Some thing like:
 DateTime dateTime;
 dateTime = getCurrentDateTime();

http://d-programming-language.org/intro-to-datetime.html
Oct 06 2011
next sibling parent reply Jacob Carlborg <doob me.com> writes:
On 2011-10-07 08:15, Jonathan M Davis wrote:
 On Friday, October 07, 2011 19:08:33 Joel Christensen wrote:
 Hi,

 I have a program that uses the old time stuff before the module
 std.datetime. I have a DateTime object, but I can't seem to set its
 properties to the current time.

 Some thing like:
 DateTime dateTime;
 dateTime = getCurrentDateTime();

http://d-programming-language.org/intro-to-datetime.html

May I suggest that you put an example on top of that article that gets the current date and time. -- /Jacob Carlborg
Oct 06 2011
parent reply Jonathan M Davis <jmdavisProg gmx.com> writes:
On Thursday, October 06, 2011 23:31:26 Jonathan M Davis wrote:
 On Friday, October 07, 2011 08:23:10 Jacob Carlborg wrote:
 On 2011-10-07 08:15, Jonathan M Davis wrote:
 On Friday, October 07, 2011 19:08:33 Joel Christensen wrote:
 Hi,
 
 I have a program that uses the old time stuff before the module
 std.datetime. I have a DateTime object, but I can't seem to set
 its
 properties to the current time.
 
 Some thing like:
 DateTime dateTime;
 dateTime = getCurrentDateTime();

http://d-programming-language.org/intro-to-datetime.html

May I suggest that you put an example on top of that article that gets the current date and time.

It's already in the documentation at the top of the module. What I need to do is put a link to the article in that documetantion.

I just added a link to the article to std.datetime, so it'll be there starting with the next release. What I'd _really_ like to see fixed though is the anchor-generation with ddoc so that I can actually properly organize the links at the top of std.datetime. - Jonathan M Davis
Oct 06 2011
parent Jacob Carlborg <doob me.com> writes:
On 2011-10-07 08:54, Jonathan M Davis wrote:
 On Thursday, October 06, 2011 23:31:26 Jonathan M Davis wrote:
 On Friday, October 07, 2011 08:23:10 Jacob Carlborg wrote:
 On 2011-10-07 08:15, Jonathan M Davis wrote:
 On Friday, October 07, 2011 19:08:33 Joel Christensen wrote:
 Hi,

 I have a program that uses the old time stuff before the module
 std.datetime. I have a DateTime object, but I can't seem to set
 its
 properties to the current time.

 Some thing like:
 DateTime dateTime;
 dateTime = getCurrentDateTime();

http://d-programming-language.org/intro-to-datetime.html

May I suggest that you put an example on top of that article that gets the current date and time.

It's already in the documentation at the top of the module. What I need to do is put a link to the article in that documetantion.

I just added a link to the article to std.datetime, so it'll be there starting with the next release. What I'd _really_ like to see fixed though is the anchor-generation with ddoc so that I can actually properly organize the links at the top of std.datetime. - Jonathan M Davis

That would be nice too. -- /Jacob Carlborg
Oct 07 2011
prev sibling parent Joel Christensen <joelcnz gmail.com> writes:
 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 -JoelCNZ
Oct 06 2011
prev sibling next sibling parent Jonathan M Davis <jmdavisProg gmx.com> writes:
On Friday, October 07, 2011 08:23:10 Jacob Carlborg wrote:
 On 2011-10-07 08:15, Jonathan M Davis wrote:
 On Friday, October 07, 2011 19:08:33 Joel Christensen wrote:
 Hi,
 
 I have a program that uses the old time stuff before the module
 std.datetime. I have a DateTime object, but I can't seem to set its
 properties to the current time.
 
 Some thing like:
 DateTime dateTime;
 dateTime = getCurrentDateTime();

http://d-programming-language.org/intro-to-datetime.html

May I suggest that you put an example on top of that article that gets the current date and time.

It's already in the documentation at the top of the module. What I need to do is put a link to the article in that documetantion. - Jonathan M Davis
Oct 06 2011
prev sibling parent Jonathan M Davis <jmdavisProg gmx.com> writes:
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
Oct 24 2011