📄 time.cpp
字号:
/*
Copyright 2006 - 2008, All Rights Reserved.
利用这个类获取系统时间
作者 - 张鲁夺(zhangluduo)
MSN - zhangluduo@msn.com
QQ群 - 34064264
为所有爱我的人和我爱的人努力!
*/
#include "stdafx.h"
#include "Time.h"
#include <TIME.H>
#include <sys\timeb.h>
Time::Time()
{
Update();
}
Time::~Time()
{
}
void Time::Update()
{
// #ifndef _TIMEB_DEFINED
// struct _timeb {
// time_t time;
// unsigned short millitm;
// short timezone;
// short dstflag;
// };
//
// #if !__STDC__
//
// /* Non-ANSI name for compatibility */
//
// struct timeb {
// time_t time;
// unsigned short millitm;
// short timezone;
// short dstflag;
// };
//
// #endif
//
// #define _TIMEB_DEFINED
// #endif
//
// #ifndef _TM_DEFINED
// struct tm {
// int tm_sec; /* seconds after the minute - [0,59] */
// int tm_min; /* minutes after the hour - [0,59] */
// int tm_hour; /* hours since midnight - [0,23] */
// int tm_mday; /* day of the month - [1,31] */
// int tm_mon; /* months since January - [0,11] */
// int tm_year; /* years since 1900 */
// int tm_wday; /* days since Sunday - [0,6] */
// int tm_yday; /* days since January 1 - [0,365] */
// int tm_isdst; /* daylight savings time flag */
// };
// #define _TM_DEFINED
// #endif
struct _timeb timebuffer;
_ftime( &timebuffer );
struct tm *today = localtime( &timebuffer.time );
m_TIME.nYear = today->tm_year + 1900;
m_TIME.nMonth = today->tm_mon + 1;
m_TIME.nDay = today->tm_mday;
m_TIME.nHour = today->tm_hour;
m_TIME.nMinute = today->tm_min;
m_TIME.nSecond = today->tm_sec;
m_TIME.nMillisecond = timebuffer.millitm;
m_TIME.nWeek = today->tm_wday;
}
int Time::GetYear()
{
return m_TIME.nYear;
}
int Time::GetMonth()
{
return m_TIME.nMonth;
}
int Time::GetDay()
{
return m_TIME.nDay;
}
int Time::GetHour()
{
return m_TIME.nHour;
}
int Time::GetMinute()
{
return m_TIME.nMinute;
}
int Time::GetSecond()
{
return m_TIME.nSecond;
}
int Time::GetMillisecond()
{
return m_TIME.nMillisecond;
}
int Time::GetWeek()
{
return m_TIME.nWeek;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -