StrToTime.cpp
资源名称:停车场管理系统.zip [点击查看]
上传用户:trilite
上传日期:2007-04-24
资源大小:261k
文件大小:1k
源码类别:
酒店行业
开发平台:
Visual C++
- // StrToTime.cpp: implementation of the StrToTime class.
- //
- //////////////////////////////////////////////////////////////////////
- #include "stdafx.h"
- #include "StrToTime.h"
- #ifdef _DEBUG
- #undef THIS_FILE
- static char THIS_FILE[]=__FILE__;
- #define new DEBUG_NEW
- #endif
- //////////////////////////////////////////////////////////////////////
- // Construction/Destruction
- //////////////////////////////////////////////////////////////////////
- CStrToTime::CStrToTime()
- {
- }
- CStrToTime::~CStrToTime()
- {
- }
- CTime CStrToTime::FormatDateTime(CString strTime)
- {
- int year,month,day,hour,minute,second;
- year = atoi(strTime.Mid(0,4));
- month = atoi(strTime.Mid(5,2));
- day = atoi(strTime.Mid(8,2));
- hour = atoi(strTime.Mid(11,2));
- minute = atoi(strTime.Mid(14,2));
- if (strTime.GetLength() >= 17)
- {
- second = atoi(strTime.Mid(17,2));
- }
- else
- {
- second = 0;
- }
- CTime time(year,month,day,hour,minute,second,-1);
- return time;
- }
- CTime CStrToTime::FormatDate(CString strTime)
- {
- int year,month,day;
- year = atoi(strTime.Mid(0,4));
- month = atoi(strTime.Mid(5,2));
- day = atoi(strTime.Mid(8,2));
- CTime time(year,month,day,12,0,0,-1);
- return time;
- }
- CTime CStrToTime::FormatTime(CString strTime)
- {
- int hour,minute,second;
- hour = atoi(strTime.Mid(0,2));
- minute = atoi(strTime.Mid(3,2));
- if (strTime.GetLength() >= 6)
- {
- second = atoi(strTime.Mid(6,2));
- }
- else
- {
- second = 0;
- }
- CTime time(2000,1,1,hour,minute,second,-1);
- return time;
- }