📄 revokecert.cpp
字号:
// RevokeCert.cpp: implementation of the CRevokeCert class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "RevokeCert.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
IMPLEMENT_SERIAL(CRevokeCert, CObject,0)
CRevokeCert::CRevokeCert()
{
}
CRevokeCert::CRevokeCert(CString strSN,CString strTime)
{
this->strSN = strSN;
this->strTime = strTime;
}
CRevokeCert::~CRevokeCert()
{
}
long CRevokeCert::GetSNWithLong()
{
return atol((char*)(LPCTSTR)strSN);
}
char* CRevokeCert::GetTimeStr()
{
return (char*)(LPCTSTR)strTime;
}
char* CRevokeCert::GetSNStr()
{
return (char*)(LPCTSTR)strSN;
}
time_t CRevokeCert::GetTime()
{
//Format "%04d-%02d-%02d %02d:%02d:%02d"
struct tm stTIME;
char buf[64]= {0};
char tmp[10]= {0};
char *p=buf;
// 格式检查
if(CheckTimeFormat((char*)(LPCTSTR)strTime)!=1)
return -1L;
strcpy(buf,(const char*)(LPCTSTR)strTime);
// 年
memcpy(tmp,p,4);
p+=5;
tmp[4]='\0';
stTIME.tm_year = atoi(tmp)-1900;
// 月
memcpy(tmp,p,2);
p+=3;
tmp[2]='\0';
stTIME.tm_mon = atoi(tmp);
// 日
memcpy(tmp,p,2);
p+=3;
tmp[2]='\0';
stTIME.tm_mday = atoi(tmp);
// 时
memcpy(tmp,p,2);
p+=3;
tmp[2]='\0';
stTIME.tm_hour = atoi(tmp);
// 分
memcpy(tmp,p,2);
p+=3;
tmp[2]='\0';
stTIME.tm_min = atoi(tmp);
// 秒
memcpy(tmp,p,2);
p+=3;
tmp[2]='\0';
stTIME.tm_sec = atoi(tmp);
return mktime(&stTIME);
}
int CRevokeCert::CheckTimeFormat(char* pszTime)
{
int ret = 1;
// 长度检查
if(strlen("2004-02-04 11:06:30")!=strlen(pszTime))
ret = 0;
// 格式检查
if(pszTime[4]!='-'||pszTime[7]!='-'|| pszTime[10]!=' '
|| pszTime[13]!=':'||pszTime[16]!=':')
ret = 0;
return ret;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -