On Tue, 05 Apr 2011 17:40:12 -0400, Steven Schveighoffer <[email protected]> wrote:

On Tue, 05 Apr 2011 17:24:11 -0400, Kai Meyer <[email protected]> wrote:

I'm reading documentation on std.datetime, and it appears there are added features that I don't have in 2.51 (Linux). Did features like 'SysTime' get added after 2.51?

Does anybody have a one-liner to convert a time_t to a date string that should work for me?

auto t = time();
auto systime = SystemTime(unixTimeToStdTime(t)); // to system time

from there, you have many options to create the right string. You can start with just writing it (via toString):

writeln(systime);

There's also:

http://www.digitalmars.com/d/2.0/phobos/std_datetime.html#toSimpleString
http://www.digitalmars.com/d/2.0/phobos/std_datetime.html#toISOString
http://www.digitalmars.com/d/2.0/phobos/std_datetime.html#toISOExtendedString

and doing it directly:

writefln("%s/%s/%s", t.month, t.day, t.year);

bleh, that should have been systime.month, systime.day, systime.year

-Steve

Reply via email to