bool CMyTime::operator>(CMyTime& time) { if(GetYear()>time.GetYear())return true; if(GetYear()==time.GetYear()) { if(GetMonth()>time.GetMonth())return true; if(GetMonth()==time.GetMonth()) { if(GetDay()>time.GetDay())return true; if(GetDay()==time.GetDay()) { if(GetHour()>time.GetHour())return true; if(GetHour()==time.GetHour()) { if(GetMinute()>time.GetMinute())return true; if(GetMinute()==time.GetMinute()) { if(GetSecond()>time.GetSecond())return true; } } } } } return false; }
DWORD CSPTime::ToStockTimeSecOrder( DWORD dwStockExchange ) { if( -1 == GetTime() || GetTime() < 0 || 0 == GetTime() ) return 0; if( GetHour() < 9 || (GetHour() == 9 && GetMinute() < 30) ) return 0; CSPTime tmStart = CSPTime(GetYear(),GetMonth(),GetDay(),9,30,0); CSPTime tmEnd = CSPTime(GetYear(),GetMonth(),GetDay(),15,0,0); if( *this < tmStart ) return 0; if( *this > tmEnd ) return 14400; CSPTimeSpan tmSpan = *this - tmStart; int nSec = tmSpan.GetTotalSeconds(); if( nSec >= 0 && nSec <= 7200 ) return nSec; if( nSec > 7200 && nSec < 12600 ) return 7200; if( nSec >= 12600 && nSec <= 19800 ) return nSec-5400; ASSERT( FALSE ); return 0; }
std::string CDateTime::GetLocalTime(std::string filter){ std::string sOutput; std::ostringstream oss; if(filter == "MM/DD/YY"){ oss << std::setfill ('0') << std::setw(2); oss << GetMonth() << "/" ; oss << std::setfill ('0') << std::setw(2); oss << GetDay() << "/"; oss << std::setfill ('0') << std::setw(2); oss << (GetYear() - 2000); sOutput = oss.str(); return sOutput; } else if(filter == "MM-DD-YYYY"){ oss << std::setfill ('0') << std::setw(2); oss << GetMonth() << "/" ; oss << std::setfill ('0') << std::setw(2); oss<< GetDay() << "/" << GetYear(); sOutput = oss.str(); return sOutput; } else if(filter == "MM.DD.YYYY"){ oss << std::setfill ('0') << std::setw(2); oss << GetMonth() << "." ; oss << std::setfill ('0') << std::setw(2); oss<< GetDay() << "." << GetYear(); sOutput = oss.str(); return sOutput; } else if(filter == "HH:MM"){ oss << std::setfill ('0') << std::setw(2); oss << GetHour() << ":" ; oss << std::setfill ('0') << std::setw(2); oss<< GetMinute(); sOutput = oss.str(); return sOutput; } else if(filter == "HH:MM:SS"){ oss << std::setfill ('0') << std::setw(2); oss << GetHour() << ":" ; oss << std::setfill ('0') << std::setw(2); oss<< GetMinute() << ":"; oss << std::setfill ('0') << std::setw(2); oss<< GetSecond(); sOutput = oss.str(); return sOutput; } else if(filter == "MONTH D, YYYY"){ oss << GetMonthName() << " "; oss << GetDay() << ", " ; //oss << std::setfill ('0') << std::setw(2); oss<< GetYear(); sOutput = oss.str(); return sOutput; } return ""; }
// Months void MyDate::SubtractMonths(int lessMonths) { if (lessMonths > GetMonth()){ lessMonths -= GetMonth(); if (IsLeapYear() && GetMonth() > 2) _days--; _days -= (numDaysToMonth[GetMonth()]); } for (int i = 0; i < lessMonths; i++) { _days -= DaysInThisMonth((GetMonth() - i) % 12); } }
bool CMyCalendar::operator>(CMyCalendar& time) { if(GetYear()>time.GetYear())return true; if(GetYear()==time.GetYear()) { if(GetMonth()>time.GetMonth())return true; if(GetMonth()==time.GetMonth()) { if(GetDay()>time.GetDay())return true; } } return false; }
// return number of days in month int MyDate::DaysInThisMonth() { switch(GetMonth()) { case Jan: case Mar: case May: case Jul: case Aug: case Oct: case Dec: return 31; break; case Apr: case Jun: case Sep: case Nov: return 30; break; case Feb: if(this->IsLeapYear()) return 29; else return 28; break; } }
void XTime::GetTime(XString8 &strTime) { int v=GetDayOfWeek(); strTime=WeekDay(v); v=GetDay(); if(v<10) strTime+=",0"; else strTime+=","; strTime+=v; strTime+=' '; //v=GetMonth(); strTime+=Month(GetMonth()); strTime+=' '; strTime+=GetYear(); strTime+=' '; if (this->GetHour()<10) strTime+='0'; strTime+=GetHour(); strTime+=':'; if (this->GetMinute()<10) strTime+='0'; strTime+=GetMinute(); strTime+=':'; if (this->GetSecond()<10) strTime+='0'; strTime+=GetSecond(); strTime+=" GMT"; }
cTimeAndDate::cTimeAndDate() { time_t now; time(&now); char dateandtime[26]; strcpy(dateandtime, asctime(localtime(&now))); strtok(dateandtime," \t"); // strip off 0th string thismonth=GetMonth(strtok(NULL," \t")); thisday.ofthemonth=cString(strtok(NULL," \t")).GetInt(); strtok(NULL," \t"); //strip off more garbage so we can get the year thisyear=cString(strtok(NULL," \t")).GetInt(); *this=cTimeAndDate(thismonth,thisday.ofthemonth,thisyear); timeofday[0]=12; for(int i=1; i<13; i++) { timeofday[i]=i; timeofday[i+12]=i; } Refresh(); }
void another_hour(int mode) { if (DEBUG > 2) log_info("called %s with %d", __PRETTY_FUNCTION__, mode); time_info.hours++; if (time_info.hours >= HOURS_PER_MUD_DAY) { time_info.hours = 0; time_info.day++; weather_info.moon++; if (weather_info.moon > MAX_MOON_PHASES) weather_info.moon = 1; if (time_info.day >= DAYS_PER_MUD_MONTH) { time_info.day = 0; time_info.month++; GetMonth(time_info.month); if (time_info.month >= MONTHS_PER_MUD_YEAR) { time_info.month = 0; time_info.year++; } } } if (mode) { switch (time_info.hours) { case 0: oprintf("The moon rises high overhead.\r\n"); break; case 4: oprintf("The moon sets.\r\n"); break; case 6: weather_info.sunlight = SUN_RISE; oprintf("The sun rises in the east.\r\n"); break; case 7: weather_info.sunlight = SUN_LIGHT; oprintf("The day has begun.\r\n"); break; case 12: oprintf("It is noon.\r\n"); break; case 18: weather_info.sunlight = SUN_SET; oprintf("The sun slowly disappears in the west.\r\n"); break; case 19: weather_info.sunlight = SUN_DARK; oprintf("The night has begun.\r\n"); break; case 21: oprintf("A %s moon rises in the eastern sky.\r\n", moon_names[(weather_info.moon - 1) / 4]); break; default: break; } } }
UINT TimeManager::Time2DWORD( ) { __ENTER_FUNCTION SetTime( ) ; UINT uRet=0 ; uRet += GetYear( ) ; uRet -= 2000 ; uRet =uRet*100 ; uRet += GetMonth( )+1 ; uRet =uRet*100 ; uRet += GetDay( ) ; uRet =uRet*100 ; uRet += GetHour( ) ; uRet =uRet*100 ; uRet += GetMinute( ) ; return uRet ; __LEAVE_FUNCTION return 0 ; }
bool HasEndDate(void) const { return GetDay() != m_EndDate.GetDay() || GetMonth() != m_EndDate.GetMonth() || GetYear() != m_EndDate.GetYear() ; }
bool CMyCalendar::operator==(CMyCalendar& time) { if(GetYear()==time.GetYear()&& GetMonth()==time.GetMonth()&& GetDay()==time.GetDay()) return true; return false; }
DWORD CSPTime::ToStockTimeDay( ) { if( -1 == GetTime() || GetTime() < 0 ) return -1; if( 0 == GetTime() ) return 0; return ( GetYear() * 10000 + GetMonth() * 100 + GetDay() ); }
const Char_t *KVDatime::AsGanacqDateString() const { //Return date and time string with format "29-SEP-2005 09:42:17.00" //Copy the string immediately if you want to reuse/keep it return Form("%d-%s-%4d %02d:%02d:%02d.00", GetDay(), ((TObjString *) fmonths->At(GetMonth() - 1))->String(). Data(), GetYear(), GetHour(), GetMinute(), GetSecond()); }
void GetCalenderTime(CalenderTime *ct) { ct->second = (uint8_t)GetSecond(); ct->minute = (uint8_t)GetMinute(); ct->hour = (uint8_t)GetHour(); ct->date = (uint8_t)GetDate(); ct->month = (uint8_t)GetMonth(); ct->year = (uint8_t)GetYear(); }
void CDxDatePickerMonth::DrawMonthHeader(CDCHandle dc) { if (m_rcHeader.IsRectEmpty()) return; COleDateTime dtMonth = GetMonth(); CRect rcHeader = m_rcHeader; CRect rcLeftScroll = m_rcLeftScroll; CRect rcRightScroll = m_rcRightScroll; CRect rcClient(m_pControl->m_rcControl); //dc.Draw3dRect(0, 0, rcClient.Width(), rcClient.Height(), m_clrStaticBorder, m_clrStaticBorder); CRect rcHeaderBk = m_rcMonth; rcHeaderBk.bottom = rcHeader.bottom; // fill background dc.FillSolidRect(rcHeaderBk, RGB(191, 219, 255)); // draw header text dc.SetBkColor(GetSysColor(COLOR_BTNFACE)); dc.SetTextColor(GetSysColor(COLOR_WINDOWTEXT)); HFONT hFontOld = (HFONT)dc.SelectFont(CDxFontManager::GetSingleton().GetFont(DUIF_DEFAULTFONT)); CString strText; if (!m_pControl->m_strYearMonthFormat.IsEmpty()) { //strText = GetDateFormat(dtMonth, pControl->m_strYearMonthFormat); } else { strText.Format(_T("%s %d"), (LPCTSTR)m_pControl->GetMonthName( dtMonth.GetMonth()), dtMonth.GetYear()); } dc.DrawText(strText, strText.GetLength(), &rcHeader, DT_SINGLELINE | DT_VCENTER | DT_CENTER); // draw left scroll triangle if (!rcLeftScroll.IsRectEmpty()) { // draw left triangle itself if (GetShowLeftScroll()) DrawScrollTriangle(dc, rcLeftScroll, TRUE, m_clrMonthHeaderButton, m_pControl->m_bYearsTriangle); } // draw right scroll triangle if (!rcRightScroll.IsRectEmpty()) { // draw right triangle itself if (GetShowRightScroll()) DrawScrollTriangle(dc, rcRightScroll, FALSE, m_clrMonthHeaderButton, m_pControl->m_bYearsTriangle); } dc.SelectFont(hFontOld); }
CMyCalendar& CMyCalendar::operator-=(CMyTimeInterval& timeInterval) { if(!timeInterval.GetSingal()) { CMyTimeInterval t=timeInterval; t.SetSingal(true); return *this+=t; } int days=timeInterval.GetDays(); if(days<=0)return *this; int y=GetYear(); int m=GetMonth(); int d=GetDay(); int less=YearDaysLess(y,m,d); int uless=YearDays(y)-less; if(days<uless) { //没有跨年 if(days<d) { //没有跨月 m_Time.wDay-=days; } else { //跨月 days-=d; int md=0; while(1) { md=MonthDays(y,--m); if(md>=days)break; days-=md; } m_Time.wDay=md-days; m_Time.wMonth=m; } } else { //跨年 days-=uless; int yd=0; while(1) { yd=YearDays(--y); if(yd>=days)break; days-=yd; } m_Time.wMonth=MonthDayInYear(y,YearDays(y)-days,(int &)m_Time.wDay); m_Time.wYear=y; } m_Time.wDayOfWeek=GetWeek(m_Time.wYear,m_Time.wMonth,m_Time.wDay); return *this; }
DWORD CSPTime::ToStockTimeMin( ) { if( -1 == GetTime() || GetTime() < 0 ) return -1; if( 0 == GetTime() ) return 0; return ( (GetYear() - 1990) * 100000000 + GetMonth() * 1000000 + GetDay() * 10000 + GetHour() * 100 + GetMinute() ); }
void UKismetMathLibrary::BreakDateTime(FDateTime InDateTime, int32& Year, int32& Month, int32& Day, int32& Hour, int32& Minute, int32& Second, int32& Millisecond) { Year = GetYear(InDateTime); Month = GetMonth(InDateTime); Day = GetDay(InDateTime); Hour = GetHour(InDateTime); Minute = GetMinute(InDateTime); Second = GetSecond(InDateTime); Millisecond = GetMillisecond(InDateTime); }
std::string Logger::TimestampSS() { //get the time data, and clear the stream Reset(); //format: "Screenshots/Sept29/53700.png" sstream << "Screenshots\\" << GetMonth() << TI->tm_mday << "\\" << TI->tm_hour << TI->tm_min << TI->tm_sec << ".png"; return sstream.str(); }
CTime CDate_std::AsCTime(CTime::ETimeZone tz) const { return CTime(GetYear(), CanGetMonth() ? GetMonth() : 1, CanGetDay() ? GetDay() : 1, CanGetHour() ? GetHour() : 0, CanGetMinute() ? GetMinute() : 0, CanGetSecond() ? GetSecond() : 0, 0, // nanoseconds, not supported by CDate_std. tz); }
/* Gets Date for GetLastCallers(), returns DD:Mmm */ char *GLCdate() { static char GLcdate[15]; Time_Now = time(NULL); l_date = localtime(&Time_Now); snprintf(GLcdate, 15, "%02d-", l_date->tm_mday); strcat(GLcdate,GetMonth(l_date->tm_mon+1)); return(GLcdate); }
// SetMonth // Takes an int argument // sets month of year ( jan = 1 dec = 12) void MyDate::SetMonth(int newMonth) { int oldMonth = GetMonth(); int year = GetYear() + 1; // remove _days for old month _days -= numDaysToMonth[oldMonth]; if (oldMonth > 2 && IsLeapYear(year)) _days--; // add _days for new month _days += numDaysToMonth[newMonth]; if (newMonth > 2 && IsLeapYear(year)) _days++; }
void DWordToDate(DWORD dwDate,LPSTR szBuffer) { if (dwDate==0) { szBuffer[0]=0; } else { WORD wYear=GetYear(dwDate); WORD wMonth=GetMonth(dwDate); WORD wDay=GetDay(dwDate); sprintf(szBuffer,"%.4i,%.2i,%.2i",(int)wYear,(int)wMonth,(int)wDay); } }
tuint32 TimeManager::Time2Day() { tuint32 uRet = 0; uRet += GetYear(); uRet *= 100; uRet += GetMonth() + 1; uRet *= 100; uRet += GetDay(); return uRet; }
CDateTime & CDateTime::IncMonth(UINT32 month) { m_time.tm_year += (m_time.tm_mon + month)/12; m_time.tm_mon = (m_time.tm_mon + month)%12; UINT32 month_days = GetDaysOfYearMonth(GetYear(),GetMonth()); if (m_time.tm_mday > month_days) { m_time.tm_mon += 1; if (m_time.tm_mon >= 12) { m_time.tm_mon = 0; } m_time.tm_mday -= month_days; } assert(_CheckYearIsRight() == true); return *this; }
// GetDay // returns int day of month int MyDate::GetDay() { int year = GetYear(); int month = GetMonth(); int result = _days - NumDaysToYear(year); result -= numDaysToMonth[month]; if (IsLeapYear(GetYear() + 1) && GetMonth() > 2) result++; if (result == 0) result++; return result; /* int result = _days - NumDaysToYear(GetYear()); result -= numDaysToMonth[GetMonth()]; if (IsLeapYear(GetYear() + 1) && GetMonth() > 2) result++; // Adjust for loss of day on the first of some months if (result == 0) result++; return result; */ }
/* Returns DD-Mmm-YYYY */ char *GLCdateyy() { static char GLcdateyy[15]; char ntime[15]; Time_Now = time(NULL); l_date = localtime(&Time_Now); snprintf(GLcdateyy, 15, "%02d-", l_date->tm_mday); snprintf(ntime, 15, "-%02d", l_date->tm_year+1900); strcat(GLcdateyy, GetMonth(l_date->tm_mon+1)); strcat(GLcdateyy,ntime); return (GLcdateyy); }
CString GetStrDataTime(COleDateTime tm) { CString str, str1; int day = tm.GetDay(); WORD month = tm.GetMonth(); CString monthS = GetMonth(month); int year = tm.GetYear(); int hour = tm.GetHour(); int minute = tm.GetMinute(); int second = tm.GetSecond(); str.Format("%d ", day); str += monthS; str1.Format(" %d %02d:%02d:%02d", year, hour, minute, second); str += str1; return str; }
void Alo_Main(multiboot_data *multibootdata) { HAL_init(multibootdata); terminal_putstring("Hello to Alo 2!\n"); terminal_putstring(" Just testing newlines....\n"); terminal_printf("-13 when put through itoa is: %d.", -13); terminal_printf("My name is %s.", "Alex"); terminal_printf("Today is %s %d, %d. It is a %s. It is %d:%d:%d military time.", GetMonth(), GetDayInMonth(), GetYear(), GetWeekDay(), GetHour(), GetMinute(), GetSecond()); /*testtimer.limit = 100; testtimer.func = OneSecondHandler; secondtimer.limit = 200; secondtimer.func = TheResponse; Timer_Register_Timer(&testtimer); Timer_Register_Timer(&secondtimer); */ /* int test = 8/(6 - (3 * 2)); */ };