Getting the current datetime converted into a string for writing to stdout
Gary Miller
aiguy at roadrunner.com
Fri Mar 28 22:01:13 PDT 2014
I've been reading through and trying various code fragments to
pull the system date/time in and format it as a string for
display on the console.
I only need it down to the second and from my current machine so
I don't need to use any of the more accurate clocks used for
benchmarking right now.
All the examples seem to be setting the date or date time to some
predetermined value instead of pulling it from the system.
It seems like this would be a very common function to use so I
know I must be making this a lot harder than it really is.
Oh and before I forget I'd like to thank everybody on the forum
for their great support.
I'm still a newbie at D. I've bought the book. I've watched the
YouTube videos and now I'm starting to get a lot more comfortable
with the code but it feels like it's going to take me some time
to figure out the tricks for using all the library functions.
I started out trying to use strings for everything but quickly
found that my code is doing a lot of string modification
concatenation and I had to switch to char[] instead to get around
the immutability but now a lot of the library functions use the
string data type so I am having to figure out how to convert
between back and forth between all the different datatypes.
It would be nice if all the primitive datatypes had a consistent
toString cast or function but since I'm not seeing those I guess
writeFormatted must be the preferred way of getting values into
string format.
More information about the Digitalmars-d-learn
mailing list