polo021 | je suis en forme
Code :
- CString CClasse::GetTime()
- {
- //timte and date
- CTime t = CTime::GetCurrentTime();
- CString month;
- switch( t.GetMonth() )
- {
- case 1: month = "JAN"; break;
- case 2: month = "FEB"; break;
- case 3: month = "MAR"; break;
- case 4: month = "APR"; break;
- case 5: month = "MAY"; break;
- case 6: month = "JUN"; break;
- case 7: month = "JUL"; break;
- case 8: month = "AUG"; break;
- case 9: month = "SEP"; break;
- case 10: month = "OCT"; break;
- case 11: month = "NOV"; break;
- case 12: month = "DEC"; break;
- default: month = "ERR"; break;
- }
- //if <10 ajouter 0 en pos 0 ds la cstring, pour avoir 01 au lieu de 1
- CString day;
- char temp_time[2];
- _itoa(t.GetDay(),temp_time,10);
- day = temp_time;
- if (t.GetDay()<10)
- {
- day.Insert(0,'0');
- }
- CString hour;
- int h = t.GetHour();
- _itoa(h,temp_time,10);
- hour = temp_time;
- if (h<10)
- hour.Insert(0,'0');
- CString minute;
- int m = t.GetMinute();
- _itoa(m,temp_time,10);
- minute = temp_time;
- if (m<10)
- minute.Insert(0,'0');
- return (day+month+hour+minute);
- }
|
pour l'annee t'as qu'a creuser un peu |