#include "stdafx.h"#include "FormatTime.h"std::string FormatTime::FormatTimestamp(int nTimestamp, int nTimezone, FormatTimeType eFmtType){time_t nTime = nTimestamp + 3600 * nTimezone;struct tm *stTime = gmtime(&nTime);return FormatTimeStruct(stTime->tm_year + 1900, stTime->tm_mon + 1, stTime->tm_mday, stTime->tm_hour, stTime->tm_min, stTime->tm_sec, eFmtType);}std::string FormatTime::FormatTimeStruct(int nYear, int nMonth, int nDay, int nHour, int nMin, int nSec, FormatTimeType eFmtType){char szFmtBuf[64] = {};switch (eFmtType){case FormatTime_YMDHMS:sprintf_s(szFmtBuf, "%d-%02d-%02d %02d:%02d:%02d", nYear, nMonth, nDay, nHour, nMin, nSec);break;case FormatTime_YMD:sprintf_s(szFmtBuf, "%d-%02d-%02d", nYear, nMonth, nDay);break;case FormatTime_HMS:sprintf_s(szFmtBuf, "%02d:%02d:%02d", nHour, nMin, nSec);break;case FormatTime_MDHM:sprintf_s(szFmtBuf, "%02d-%02d %02d:%02d", nMonth, nDay, nHour, nMin);break;default:assert(0);break;}std::string strRet(szFmtBuf);return strRet;}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。