www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Populating Date struct from d_time value

reply Steve Teale <steve.teale britseyeview.com> writes:
What is the recommended way of populating a std.date Date struct from a d_time
value returned by getUTCtime()?

I'm probably being very dense, but it seems to me that at present I have to
convert the d_time value to a formatted date string, and then parse that. This
seems very inefficient.

Also, Date has a weekday member, but no year day, and year days are quite
widely used.
Mar 15 2009
parent Walter Bright <newshound1 digitalmars.com> writes:
Steve Teale wrote:
 What is the recommended way of populating a std.date Date struct from
 a d_time value returned by getUTCtime()?
 
 I'm probably being very dense, but it seems to me that at present I
 have to convert the d_time value to a formatted date string, and then
 parse that. This seems very inefficient.
There isn't a function to do it directly, but you can use YearFromTime(t), MonthFromTime(t), etc.
 Also, Date has a weekday member, but no year day, and year days are
 quite widely used.
Day(t) - DayFromYear(YearFromTime(t))
Mar 15 2009