D
Dj Frenzy
Hi,
this should be a pretty easy question for the advanced people on
here. Basically , I have two strings:
string transDate = "20030901";
string transTime = "1200";
I want to know the best way to reformat them into a more recognisable
format so that:
transDate = "01/09/2003";
transTime = "12:00";
At the moment I just have a function like this:
string formatDate (string &oldFormat)
{
string newFormat;
newFormat.push_back(oldFormat[6]);
newFormat.push_back(oldFormat[7]);
newFormat.push_back('/');
newFormat.push_back(oldFormat[4]);
newFormat.push_back(oldFormat[5]);
newFormat.push_back('/');
newFormat.push_back(oldFormat[0]);
newFormat.push_back(oldFormat[1]);
newFormat.push_back(oldFormat[2]);
newFormat.push_back(oldFormat[3]);
return newFormat;
}
The function for formatTime is very similar. Can anyone give me any
help on how to use better programming to change the format, using
something from the standard template library maybe?
Cheers
Dave
this should be a pretty easy question for the advanced people on
here. Basically , I have two strings:
string transDate = "20030901";
string transTime = "1200";
I want to know the best way to reformat them into a more recognisable
format so that:
transDate = "01/09/2003";
transTime = "12:00";
At the moment I just have a function like this:
string formatDate (string &oldFormat)
{
string newFormat;
newFormat.push_back(oldFormat[6]);
newFormat.push_back(oldFormat[7]);
newFormat.push_back('/');
newFormat.push_back(oldFormat[4]);
newFormat.push_back(oldFormat[5]);
newFormat.push_back('/');
newFormat.push_back(oldFormat[0]);
newFormat.push_back(oldFormat[1]);
newFormat.push_back(oldFormat[2]);
newFormat.push_back(oldFormat[3]);
return newFormat;
}
The function for formatTime is very similar. Can anyone give me any
help on how to use better programming to change the format, using
something from the standard template library maybe?
Cheers
Dave