On 04/05/2011 03:40 PM, Steven Schveighoffer 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);

Don't see a way to print the month in text format, but maybe I'm
overlooking it.

-Steve

Ok, that works. Thanks :)

Reply via email to