// MyTime.h: interface for the CMyTime class.
//
//
#if !defined(AFX_MYTIME_H__9B47C165_ED21_464C_92C3_4184CEBF2766__INCLUDED_)
#define AFX_MYTIME_H__9B47C165_ED21_464C_92C3_4184CEBF2766__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
class CMyTime
{
public:
CMyTime();
virtual ~CMyTime();
CTime time;
CString GetAllString(BOOL bChinese);
CString GetDateString(BOOL bChinese);
CString GetTimeString(BOOL bChinese);
CString GetSimpleString();
CString GetWeekDay();
void SetAllString(CString strTime, BOOL bSimple);
void SetNow();
};
#endif // !defined(AFX_MYTIME_H__9B47C165_ED21_464C_92C3_4184CEBF2766__INCLUDED_)
// MyTime.cpp: implementation of the CMyTime class.
//
//
#include "stdafx.h"
//#include "SalesManagementSystem.h"
#include "MyTime.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//
// Construction/Destruction
//
CMyTime::CMyTime()
{
time = CTime::GetCurrentTime();
}
CMyTime::~CMyTime()
{
}
/************************************************************************
函数名: GetAllString
作 者: 谭友亮(Charles Tan)
日 期: 2013-3-22
作 用: 返回字符串形式的日期时间
形参数: bChinese:TRUE-"年月日时分秒" FALSE-"-:"
返回值:
修改记录:
************************************************************************/
CString CMyTime::GetAllString(BOOL bChinese)
{
CString strTime;
if (bChinese)
{
strTime = time.Format("%Y年%m月%d日 %H时%M分%S秒");
}
else
{
strTime = time.Format("%Y-%m-%d %H:%M:%S");
}
return strTime;
}
/************************************************************************
函数名: GetDateString
作 者: 谭友亮(Charles Tan)
日 期: 2013-3-22
作 用: 返回字符串形式的日期
形参数: bChinese:TRUE-"年月日" FALSE-"-:"
返回值:
修改记录:
************************************************************************/
CString CMyTime::GetDateString(BOOL bChinese)
{
CString strTime;
if (bChinese)
{
strTime = time.Format("%Y年%m月%d日");
}
else
{
strTime = time.Format("%Y-%m-%d");
}
return strTime;
}
/************************************************************************
函数名: GetTimeString
作 者: 谭友亮(Charles Tan)
日 期: 2013-3-22
作 用: 返回字符串形式的时间
形参数: bChinese:TRUE-"年月日时分秒" FALSE-"-:"
返回值:
修改记录:
************************************************************************/
CString CMyTime::GetTimeString(BOOL bChinese)
{
CString strTime;
if (bChinese)
{
strTime = time.Format("%H时%M分%S秒");
}
else
{
strTime = time.Format("%H:%M:%S");
}
return strTime;
}
/************************************************************************
函数名: GetSimpleString
作 者: 谭友亮(Charles Tan)
日 期: 2013-3-22
作 用: 返回简单字符串形式的日期时间
形参数:
返回值:
修改记录:
************************************************************************/
CString CMyTime::GetSimpleString()
{
CString strTime = time.Format("%Y%m%d%H%M%S");
return strTime;
}
/************************************************************************
函数名: GetWeekDay
作 者: 谭友亮(Charles Tan)
日 期: 2013-3-22
作 用: 返回星期
形参数:
返回值:
修改记录:
************************************************************************/
CString CMyTime::GetWeekDay()
{
CString strWeekDay;
CString strWeek[7] = {"日","一","二","三","四","五","六"};
strWeekDay = "星期" + strWeek[time.GetDayOfWeek() - 1];
return strWeekDay;
}
商店管理系统源代码(四)
最新推荐文章于 2014-05-22 08:22:54 发布