VC time operations seem to be a headache, especially for some new users. Here we provide some time operation examples for your reference.
Time Acquisition:
// Obtain the system date
Cstring getsysdate ()
{
Ctime TM = ctime: getcurrenttime ();
Int year = TM. getyear ();
Int mouth = TM. getmonth ();
Int day = TM. getday ();
Cstring required IME = "";
Required ime. Format ("% d-% d", year, Mouth, Day );
Return required IME;
}
// Obtain the system time
Cstring getpolicime ()
{
Ctime TM = ctime: getcurrenttime ();
Int hour = TM. gethour ();
Int min = TM. getminute ();
Int sec = TM. getsecond ();
Cstring required IME = "";
Systime. Format ("% d: % d", hour, Min, Sec );
Return required IME;
}
// Obtain the system date package scratch time
Cstring getpolicime ()
{
Ctime TM = ctime: getcurrenttime ();
Int year = TM. getyear ();
Int mouth = TM. getmonth ();
Int day = TM. getday ();
Int hour = TM. gethour ();
Int min = TM. getminute ();
Int sec = TM. getsecond ();
Cstring required IME = "";
Systime. Format ("(" % d-% d: % d ", year, Mouth, day, hour, Min, Sec );
Return required IME;
}
// Obtain the year
Int getyear ()
{
Ctime TM = ctime: getcurrenttime ();
Return TM. getyear ();
}
// Obtain the month
Int getmouth ()
{
Ctime TM = ctime: getcurrenttime ();
Return TM. getmonth ();
}
// Obtain the day
Int getday ()
{
Ctime TM = ctime: getcurrenttime ();
Return TM. getday ();
}
// Obtain
Int gethour ()
{
Ctime TM = ctime: getcurrenttime ();
Return TM. gethour ();
}
// Obtain the score
Int getminu ()
{
Ctime TM = ctime: getcurrenttime ();
Return TM. getminute ();
}
// Obtain the second
Int getsec ()
{
Ctime TM = ctime: getcurrenttime ();
Return TM. getsecond ();
}
// Calculate the difference between the two time ranges
Int timejianfa (INT Y1, int M1, int D1, int H1, int ms1, int S1, int Y2, int m2, int D2, int H2, int MS2, int S2)
{
Ctime m_time1 (Y1, M1, D1, H1, ms1, S1 );
Ctime m_time2 (Y2, M2, D2, H2, MS2, S2 );
Uint T1 = m_time1.gettime ();
Uint t2 = m_time2.gettime ();
Uint mdelta = t2-T1;
Int mday = mdelta;
Return mday;
}