STD: String inttostring (int I)
{
Char tmpbuf [20];
ITOA (I, tmpbuf, 10 );
Return STD: string (tmpbuf );
}
Int stringtoint (STD: String Str)
{
Return atoi (Str. c_str ());
}
// Convert the time to "year-month-day: minute: Second" string format
STD: String timetostring (Tm * time, STD: String daysplite = "-", STD: String daytimesplite = "", STD: String timesplite = ":");
STD: String timetostring (Tm * time, STD: String daysplite, STD: String daytimesplite, STD: String timesplite)
{
String tstr = inttostring (time-> maid + 1900 );
Tstr + = daysplite;
If (inttostring (time-> tm_mon + 1). Length () = 1)
Tstr + = "0 ";
Tstr + = inttostring (time-> tm_mon + 1 );
Tstr + = daysplite;
If (inttostring (time-> tm_mday). Length () = 1)
Tstr + = "0 ";
Tstr + = inttostring (time-> tm_mday );
Tstr + = daytimesplite;
If (inttostring (time-> tm_hour). Length () = 1)
Tstr + = "0 ";
Tstr + = inttostring (time-> tm_hour );
Tstr + = timesplite;
If (inttostring (time-> tm_min). Length () = 1)
Tstr + = "0 ";
Tstr + = inttostring (time-> tm_min );
Tstr + = timesplite;
If (inttostring (time-> tm_sec). Length () = 1)
Tstr + = "0 ";
Tstr + = inttostring (time-> tm_sec );
Return tstr;
}
// Convert Greenwich Mean Time (to the current number of seconds) to the format of "year-month-day hour: minute: second"
String _ API timetostring (time_t max );
String timetostring (time_t max)
{
Time_t value = max;
TM * time = localtime (& value );
String tstr = timetostring (time ,"-","",":");
Return tstr;
}
// Convert the time in the format of "year-month-day hour: minute: Second" to Greenwich Mean Time (1900.1.1 to the current number of seconds)
Time_t convertmytimetotimet (string strtime );
Time_t convertmytimetotimet (string strtime)
{
Tm t;
Memset (& T, 0, sizeof (t ));
T. tm_year = stringtoint (strtime. substr (1900;
T. tm_mon = stringtoint (strtime. substr (5, 2)-1;
T. tm_mday = stringtoint (strtime. substr (8, 2 ));
T. tm_hour = stringtoint (strtime. substr (11,2 ));
T. tm_min = stringtoint (strtime. substr (14,2 ));
T. tm_sec = stringtoint (strtime. substr (17,2 ));
Return _ mktime64 (& T );
}