// Convert the character format to time. True: add one day; false: minus one day
// Convert the character format to time
Cstring cgrossprofitratioreportdlg: strtodate (cstring strtime, bool baddorplus)
{
Cstring STR (strtime );
Int year, month, day, hour, Minite, second;
Sscanf (STR, "% d-% d: % d", & year, & month, & day, & hour, & Minite, & second );
Coledatetime time (year, month, day, hour, Minite, second );
Coledatetimespan oneday (1); // Time Difference per day
If (baddorplus)
{
Time + = oneday; // the next day
}
Else
{
Time-= oneday; // the previous day
}
Cstring strdate;
Strdate = time. Format ("% Y-% m-% d ");
Return strdate;
}
2.
Cstring STR ("14:00:35 ");
Int nyear, nmonth, nday, nhour, nminite, nsecond;
Sscanf (STR, "% d-% d: % d ",
& Nyear, & nmonth, & nday, & nhour, & nminite, & nsecond );
Ctime time (nyear, nmonth, nday, nhour, nminite, nsecond); top
3.
Use coledatetime, ctime Function Coledatetime has.
Coledatetime oletime1 = coledatetime: getcurrenttime ();
Coledatetime oletime2;
Cstring STR = "12:12:12"
Oletime2.parsedatetime (STR );
If (oletime2> oletime) // coledatetime reloads the comparison operator