本文整理汇总了C++中DateTime::GetYear方法的典型用法代码示例。如果您正苦于以下问题:C++ DateTime::GetYear方法的具体用法?C++ DateTime::GetYear怎么用?C++ DateTime::GetYear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DateTime
的用法示例。
在下文中一共展示了DateTime::GetYear方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetInternalDate_DatePlusTimeZone
String
MailImporter::GetInternalDate_(shared_ptr<MessageData> pMsgData)
{
String sReceivedHeader = pMsgData->GetFieldValue("Received");
if (!sReceivedHeader.IsEmpty())
{
DateTime dtTime = Utilities::GetDateTimeFromReceivedHeader(sReceivedHeader);
if (dtTime.GetYear() > 1980 && dtTime.GetYear() < 2040)
{
return GetInternalDate_DatePlusTimeZone(dtTime);
}
}
// We could not determine the date by looking at the Received header, check
// the Date header insetad.
String sDateHeader = pMsgData->GetFieldValue("Date");
if (!sDateHeader.IsEmpty())
{
DateTime dtTime = Time::GetDateTimeFromMimeHeader(sDateHeader);
if (dtTime.GetYear() > 1980 && dtTime.GetYear() < 2040)
{
return GetInternalDate_DatePlusTimeZone(dtTime);
}
}
// We didn't find it in the Date header either. Use the current date.
String sCurrentTime = Time::GetCurrentDateTime();
return sCurrentTime;
}
示例2: xmBadaStat
KDint xmBadaStat ( const KDchar* path, struct stat* buf )
{
struct tm t;
FileAttributes attr;
DateTime dt;
result r;
r = File::GetAttributes ( path, attr );
if ( IsFailed ( r ) )
{
goto failed;
}
dt = attr.GetLastModifiedTime ( );
t.tm_year = dt.GetYear ( );
t.tm_mon = dt.GetMonth ( ) - 1;
t.tm_mday = dt.GetDay ( );
t.tm_hour = dt.GetHour ( );
t.tm_min = dt.GetMinute ( );
t.tm_sec = dt.GetSecond ( );
buf->st_mtime = mktime ( &t );
buf->st_mode = attr.IsDirectory ( ) ? 0x4000 : 0x8000;
buf->st_size = attr.GetFileSize ( );
return 0;
failed :
xmBadaSetError ( r );
return -1;
}
示例3: Startup
bool CServerDlg::Startup()
{
g_timerThreads.push_back(new Thread(Timer_CheckAliveTest));
g_timerThreads.push_back(new Thread(Timer_CheckLiveTimes));
m_sMapEventNpc = 0;
m_bFirstServerFlag = false;
// Server Start
DateTime time;
printf("Server started on %04d-%02d-%02d at %02d:%02d\n\n", time.GetYear(), time.GetMonth(), time.GetDay(), time.GetHour(), time.GetMinute());
//----------------------------------------------------------------------
// DB part initialize
//----------------------------------------------------------------------
GetServerInfoIni();
if (!m_GameDB.Connect(m_strGameDSN, m_strGameUID, m_strGamePWD, false))
{
OdbcError *pError = m_GameDB.GetError();
printf("ERROR: Could not connect to the database server, received error:\n%s\n",
pError->ErrorMessage.c_str());
delete pError;
return false;
}
//----------------------------------------------------------------------
// Communication Part Initialize ...
//----------------------------------------------------------------------
if (!m_socketMgr.Listen(m_nAIPort, MAX_SOCKET))
return false;
//----------------------------------------------------------------------
// Load tables
//----------------------------------------------------------------------
if (!GetMagicTableData()
|| !GetMagicType1Data()
|| !GetMagicType2Data()
|| !GetMagicType4Data()
|| !GetNpcItemTable()
|| !GetMakeItemGroupTable()
|| !GetMakeWeaponItemTableData()
|| !GetMakeDefensiveItemTableData()
|| !GetMakeGradeItemTableData()
|| !GetMakeLareItemTableData()
|| !GetServerResourceTable()
|| !GetNpcTableData(false)
|| !GetNpcTableData(true)
// Load maps
|| !MapFileLoad()
// Spawn NPC threads
|| !CreateNpcThread())
return false;
//----------------------------------------------------------------------
// Start NPC THREAD
//----------------------------------------------------------------------
ResumeAI();
return true;
}
示例4: CacheLog
VOID CLogFile::CacheLog(enum_LOG_LEVEL logLevel, const CHAR* pLogString , ... )
{
//等级太低,不需打印控制台和文件
if (logLevel < m_eConsoleLogLevel && logLevel < m_eFileLogLevel)
{
return ;
}
CHAR szLine[MAX_LOG_LINE] = {0};
va_list va;
va_start(va,pLogString);
#ifdef __LINUX
vsprintf(szLine,pLogString,va);
#else
vsprintf_s(szLine,MAX_LOG_LINE,pLogString,va);
#endif
va_end(va);
DateTime now;
CHAR szLogStr[MAX_LOG_LINE] = {'\0'};
_snprintf(szLogStr, MAX_LOG_LINE-1, "%2d/%02d/%02d %02d:%02d:%02d.%03d tId:%ld %s\n",
now.GetYear(),
now.GetMonth(),
now.GetDay(),
now.GetHour(),
now.GetMinute(),
now.GetSecond(),
now.GetMilliSecond(),
GetThreadID(),
szLine);
//高等与控制台等级,则打印到控制台
if (logLevel >= m_eConsoleLogLevel)
{
printf("%s", szLogStr);
}
//高等与文件等级,则打印到文件
if (logLevel >= m_eFileLogLevel)
{
CSmartLock sLock(m_lock);
int strLength = strlen(szLogStr);
if (m_pWriteBuf + strLength - m_pFrontBuf >= LOG_BUF_LEN)
{
//front 缓冲满了
if (m_bBackBufAvailable)
{
//两块全满了,这条要丢。
printf("LOG LOST!!, %s", szLogStr);
return;
}
//back空着,将front交换到back
SwitchBuf();
}
//写入front
strcpy( m_pWriteBuf, szLogStr );
m_pWriteBuf += strLength;
}
}
示例5: IsChangedDate
bool JMChattControl::IsChangedDate(DateTime timeSend)
{
int nElementCount=0;
nElementCount = __pArrayChattData->GetCount();
if( nElementCount < 1 )
return true;
int nNewYear=0, nNewMonth=0, nNewDate=0, nLastYear=0, nLastMonth=0, nLastDate=0;
stCHATT_DATA* pChattData = null;
nNewYear = timeSend.GetYear();
nNewMonth = timeSend.GetMonth();
nNewDate = timeSend.GetDay();
pChattData = (stCHATT_DATA*)(__pArrayChattData->GetAt(nElementCount-1));
nLastYear = pChattData->timeSend.GetYear();
nLastMonth = pChattData->timeSend.GetMonth();
nLastDate = pChattData->timeSend.GetDay();
if( nNewYear == nLastYear && nNewMonth == nLastMonth && nNewDate == nLastDate )
return false;
return true;
}
示例6:
CEbenezerDlg::CEbenezerDlg()
{
DateTime now;
m_sYear = now.GetYear();
m_sMonth = now.GetMonth();
m_sDate = now.GetDay();
m_sHour = now.GetHour();
m_sMin = now.GetMinute();
m_byWeather = 0;
m_sWeatherAmount = 0;
m_byKingWeatherEvent = 0;
m_byKingWeatherEvent_Day = 0;
m_byKingWeatherEvent_Hour = 0;
m_byKingWeatherEvent_Minute = 0;
m_byExpEventAmount = m_byCoinEventAmount = 0;
m_sPartyIndex = 0;
m_nCastleCapture = 0;
m_bKarusFlag = 0;
m_bElmoradFlag = 0;
m_byKarusOpenFlag = m_byElmoradOpenFlag = false;
m_byBanishFlag = false;
m_sBanishDelay = 0;
m_sKarusDead = 0;
m_sElmoradDead = 0;
m_bVictory = 0;
m_byOldVictory = 0;
m_byBattleSave = false;
m_sKarusCount = 0;
m_sElmoradCount = 0;
m_nBattleZoneOpenWeek=m_nBattleZoneOpenHourStart=m_nBattleZoneOpenHourEnd = 0;
m_byBattleZone = 0;
m_byBattleOpen = NO_BATTLE;
m_byOldBattleOpen = NO_BATTLE;
m_bFirstServerFlag = false;
// m_bPointCheckFlag = false;
m_bPointCheckFlag = true;
m_nServerNo = 0;
m_nServerGroupNo = 0;
m_nServerGroup = 0;
m_sDiscount = 0;
m_bPermanentChatMode = false;
m_bSantaOrAngel = FLYING_NONE;
}
示例7: getTimeAndDate
void BadaSystem::getTimeAndDate(TimeDate &td) const {
DateTime currentTime;
if (E_SUCCESS == Osp::System::SystemTime::GetCurrentTime(currentTime)) {
td.tm_sec = currentTime.GetSecond();
td.tm_min = currentTime.GetMinute();
td.tm_hour = currentTime.GetHour();
td.tm_mday = currentTime.GetDay();
td.tm_mon = currentTime.GetMonth();
td.tm_year = currentTime.GetYear();
}
}
示例8:
bool
IMAPCommandSEARCH::MatchesONCriteria_(std::shared_ptr<Message> pMessage, std::shared_ptr<IMAPSearchCriteria> pCriteria)
{
String sCreationDate = pMessage->GetCreateTime();
DateTime dt = Time::GetDateFromSystemDate(sCreationDate);
DateTime criteriaDate = Time::GetDateFromIMAP(pCriteria->GetText());
bool bMatch = false;
if (dt.GetYear() == criteriaDate.GetYear() &&
dt.GetMonth() == criteriaDate.GetMonth() &&
dt.GetDay() == criteriaDate.GetDay())
{
bMatch = true;
}
if (bMatch)
return pCriteria->GetPositive();
else
return !pCriteria->GetPositive();
}
示例9:
TEST(DateTimeTest, TestDefault)
{
DateTime defaultDate;
ASSERT_TRUE(defaultDate.WasParseSuccessful());
ASSERT_EQ(DayOfWeek::Thursday, defaultDate.GetDayOfWeek());
ASSERT_EQ(01, defaultDate.GetDay());
ASSERT_EQ(Month::January, defaultDate.GetMonth());
ASSERT_EQ(1970, defaultDate.GetYear());
ASSERT_EQ(0, defaultDate.GetHour());
ASSERT_EQ(0, defaultDate.GetMinute());
ASSERT_EQ(0, defaultDate.GetSecond());
ASSERT_EQ("Thu, 01 Jan 1970 00:00:00 GMT", defaultDate.ToGmtString(DateFormat::RFC822));
}
示例10: formatDate
String Utils::formatDate(DateTime dateTime){
int day= dateTime.GetDay();;
int month= dateTime.GetMonth();
int year= dateTime.GetYear();
String date = L"";
if(day<10) date.Append('0');
date.Append(day);
date.Append('/');
if(month<10) date.Append('0');
date.Append(month);
date.Append('/');
date.Append(year);
return date;
}
示例11:
void
POP3ClientConnection::RetrieveReceivedDate_(std::shared_ptr<MimeHeader> pHeader)
{
if (!account_->GetProcessMIMEDate())
return;
String sReceivedHeader = pHeader->GetRawFieldValue("Received");
DateTime dtTime = Utilities::GetDateTimeFromReceivedHeader(sReceivedHeader);
if (dtTime.GetYear() < 1980 || dtTime.GetYear() > 2040)
return;
long minutes = Time::GetUTCRelationMinutes();
DateTimeSpan dtSpan;
dtSpan.SetDateTimeSpan(0, 0, minutes, 0);
dtTime = dtTime + dtSpan;
String sDate = Time::GetTimeStampFromDateTime(dtTime);
current_message_->SetCreateTime(sDate);
}
示例12: getTimeAndDate
void TizenSystem::getTimeAndDate(TimeDate &td) const {
DateTime currentTime;
if (E_SUCCESS == SystemTime::GetCurrentTime(WALL_TIME, currentTime)) {
td.tm_sec = currentTime.GetSecond();
td.tm_min = currentTime.GetMinute();
td.tm_hour = currentTime.GetHour();
td.tm_mday = currentTime.GetDay();
td.tm_mon = currentTime.GetMonth();
td.tm_year = currentTime.GetYear();
Calendar *calendar = Calendar::CreateInstanceN(CALENDAR_GREGORIAN);
calendar->SetTime(currentTime);
td.tm_wday = calendar->GetTimeField(TIME_FIELD_DAY_OF_WEEK) - 1;
delete calendar;
}
}
示例13: OnInitializing
result ForUsDocForm::OnInitializing(void) {
DateTime CurDateTime;
SetFormBackEventListener(this);
result r = SystemTime::GetCurrentTime(CurDateTime);
TryReturn(!IsFailed(r), r,
"SystemTime::GetCurrentTime() failed with [%s]", GetErrorMessage(r));
r = CurDateTime.SetValue(CurDateTime.GetYear(), CurDateTime.GetMonth(), 1);
TryReturn(!IsFailed(r), r,
"DateTime::SetValue() failed with [%s]", GetErrorMessage(r));
__pSelectCalendar = Calendar::CreateInstanceN();
TryReturn(__pSelectCalendar != null, E_SYSTEM,
"Unable to get Create Instance");
r = __pSelectCalendar->SetTime(CurDateTime);
TryReturn(!IsFailed(r), r,
"Calendar::SetTime() failed with [%s]", GetErrorMessage(r));
AppLog(
"GetCurrentTime : %d/%d/%d", __pSelectCalendar->GetTimeField(TIME_FIELD_YEAR), __pSelectCalendar->GetTimeField(TIME_FIELD_MONTH), __pSelectCalendar->GetTimeField(TIME_FIELD_DAY_OF_MONTH));
r = InitializeActionControls();
TryReturn(!IsFailed(r), r,
"InitializeActionControls() failed with [%s]", GetErrorMessage(r));
r = InitializeDayNumberButtons();
TryReturn(!IsFailed(r), r,
"InitializeDayNumberButtons() failed with [%s]", GetErrorMessage(r));
TryReturn(UpdateCalendarDisplay() == true, E_SYSTEM,
"UpdateCalendarDisplay() failed");
return E_SUCCESS;
}
示例14:
void
SQLStatement::AddColumnDate(const String &sName, const DateTime & dtValue)
{
String value = Time::GetTimeStampFromDateTime(dtValue);
Column p;
p.sName = sName;
// If the date is older than 1800, don't store it. This is to solve
// limitations in SQL Server.
if (dtValue.GetStatus() == DateTime::invalid || dtValue.GetYear() < 1800)
{
p.iType = ColTypeRaw;
p.sString = "NULL";
}
else
{
p.iType = ColTypeString;
p.sString = value;
}
vecColumns.push_back(p);
}
示例15: MakeLogfilenameWithPostfix
VOID CLogFile::MakeLogfilenameWithPostfix()
{
DateTime now;
_snprintf(m_szLogFileName,MAX_FILE_NAME, "%s/%s_%.4d%.2d%.2d_%.2d%.2d%.2d_%.2d.log", m_szFilePath, m_szFileName, now.GetYear(), now.GetMonth(),
now.GetDay(), now.GetHour(), now.GetMinute(), now.GetSecond(), now.GetMilliSecond());
}