On Oct 20, 2:20*pm, ytrem...@nyx.ny x.net (Yannick Tremblay) wrote:
In article <E5%Jk.67$1K... @read4.inet.fi> ,
Juha Nieminen *<nos...@thanks .invalidwrote:
Efficiency is unlikely to be important. *strftime would be of
no use because the date is in human readable format as
suggested above, not as a tm struct. *He could possibly use
strptime to get a tm then strftime to get a string back but
simple string manipulation would do the job at least as well
and probably faster.
Just a nit, but there is no strptime in standard C++. It's a
Unix extension.
You are not comparing strftime with system(), you are
comparing strftime+strpti me with string manipulation. (but
efficiency is very unlikely to be critical)
Compared to the time necessary to spawn the child process, very,
very unlikely. Depending on what his real specification is,
there can be an advantage in passing through the numeric values
and struct tm. It's more flexible, even if it is more work.
But you still have to parse the input (boost::regex seems the
best solution for that), then if you want numeric values, use
istringstream to convert the parsed substrings. (If strptime is
available, it might be slightly easier to use, but IMHO,
learning to use boost::regex for this sort of thing is worth the
effort.) Then you reformat the data you have to get what you
want; if it's all strings, you can use either ostringstream or
string concatenation; if you have numeric values, it has to be
ostringstream.
--
James Kanze (GABI Software) email:ja******* **@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientier ter Datenverarbeitu ng
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34