VC time operation instance

Source: Internet
Author: User

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;
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.