⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 datetimeformat.h

📁 基于WINDOWS mobile 的用于创建一个窗体和自定义试图的工程
💻 H
字号:
// DateTimeFormat.h: interface for the CDateTimeFormat class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_DATETIMEFORMAT_H__6F7F9D68_B703_4159_9437_5133AAA087B5__INCLUDED_)
#define AFX_DATETIMEFORMAT_H__6F7F9D68_B703_4159_9437_5133AAA087B5__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000



//! Formats a date and time value
//
class CDateTimeFormat  
{
public:
	CDateTimeFormat();
	virtual ~CDateTimeFormat();

	//! Sets the date time value
	BOOL SetDateTime(const COleDateTime &odt);

	//! Sets the date time value
	void SetDateTime(const CTime &t);

#ifdef __oledb_h__
	//! Sets the date time value
	void SetDateTime(const DBTIMESTAMP &DbTs);
#endif

	//! Sets the format string.
	void SetFormat(LPCTSTR pszFormat);

	//! Sets the format buffer for in-place formatting.
	//! This avoids an eventual CString copy on GetString.
	void SetFormatBuf(LPTSTR pszBuf) {m_pszBuf = pszBuf;}

	//! Returns the formatted string
	LPCTSTR	GetString() {return m_pszBuf;}

protected:
	void	ClearCounters	();
	void	FormatSection	();
	void	FormatDay		();
	void	FormatMonth		();
	void	FormatYear		();
	void	FormatHour		();
	void	FormatAMPM		();
	void	FormatWeek		();
	void	FormatQuarter	();

	int		GetDayOfWeek	(int y, int m, int d);
	int		GetDayOfYear	(int y, int m, int d);
	BOOL	IsLeapYear		(int y) 
	{
		return (y % 4 == 0) && (y % 100 != 0 || y % 400 == 0);
	}

	int				m_nYear,
					m_nDayOfYear,
					m_nMonth,
					m_nDay,
					m_nDayOfWeek,
					m_nHour,
					m_nMinute,
					m_nSecond,
					m_nd,			//!< Day format
					m_nM,			//!< Month format
					m_ny,			//!< Year format
					m_nw,			//!< Week format
					m_nq,			//!< Quarter format
					m_ng,			//!< Period format
					m_nh,			//!< Hour format (12 hours)
					m_nH,			//!< Hour format (24 hours)
					m_nm,			//!< Minute format
					m_ns,			//!< Seconds format
					m_nt;			//!< Time marker
	TCHAR			m_szRes[128];	//!< Resulting formatted string
	TCHAR*			m_pszBuf;		//!< Pointer to buffer (local or not)

	void	StaticInit();

	//
	// Static members
	//
	static	BOOL	m_bStaticInit;		//!< Flag for static initializations
	static	CString	m_strMonAbbr[13],	//!< Abbreviated month names
					m_strMonFull[13],	//!< Full month names
					m_strDayAbbr[7],	//!< Abbreviated day names
					m_strDayFull[7],	//!< Full day names
					m_strAMPM[2];		//!< AM / PM indicators
	static	int		m_nMonthDays[13];	//!< Number of days in a month
};

#endif // !defined(AFX_DATETIMEFORMAT_H__6F7F9D68_B703_4159_9437_5133AAA087B5__INCLUDED_)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -