Displaying the Time in a label
Posted on 2002-04-02
I need to display the day of the week, the month and day followed by hour and minutes. Everything is fine except for the first nine minutes of every hour. This information is being formatted for display, and also saved to the registry for later displaying when the user needs to access this information.
This is what I have:
(Borland C++ Builder 4.5) -- Just listing needed info from function. (xSaved is sent to the function, taken from the stored information from the registry.)
TDateTime xDate = xSaved; // xSaved.DateTimeString();
char days = "Sun.", "Mon.", "Tue.", "Wed.", "Thu.",
"Fri.", "Sat." };
Word xYear, xMonth, xDay, xHour, xMin, xSec, xMSec;
DecodeDate(xDate, xYear, xMonth, xDay);
DecodeTime(xDate, xHour, xMin, xSec, xMSec);
String xTest = days[xDate.DayOfWeek() -1] + AnsiString(" ") + xMonth + "/" + xDay + " " + xHour + ":" + xMin + " " + ampmStr;
// xTest displays in a label as Tue. 4/2 10:8 PM. but after the first 9 minutes of the hour it displays as Tue. 4/2 10:10 PM.
I tried FormatString, but I can not get the hang of that. Can someone help me out here? Thanks.