コード例 #1
0
ファイル: MyTime.cpp プロジェクト: almondyoung/MyLibOfMySelf
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;
}
コード例 #2
0
ファイル: SpTime.cpp プロジェクト: amikey/tradingstrategyking
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;
}
コード例 #3
0
ファイル: CDateTime.cpp プロジェクト: ChuckBolin/DOS2DGame
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 "";
}
コード例 #4
0
ファイル: MyDate.cpp プロジェクト: calebthompson/School
		// 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);
		}
	}
コード例 #5
0
ファイル: MyTime.cpp プロジェクト: almondyoung/MyLibOfMySelf
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;
}
コード例 #6
0
ファイル: MyDate.cpp プロジェクト: calebthompson/School
	// 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;
		}

	}
コード例 #7
0
ファイル: XTime.cpp プロジェクト: hgl888/nashtest
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";
}
コード例 #8
0
ファイル: timeanddate.cpp プロジェクト: cmd184psu/fs-tools
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();
	
}
コード例 #9
0
ファイル: weather.c プロジェクト: Lundex/wileymud
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;
	}
    }
}
コード例 #10
0
ファイル: TimeManager.cpp プロジェクト: liub0003/BattleServer
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 ;
}
コード例 #11
0
ファイル: Calendar.cpp プロジェクト: mark711/mahogany
 bool HasEndDate(void) const
    {
       return GetDay() != m_EndDate.GetDay()
          || GetMonth() != m_EndDate.GetMonth()
          || GetYear() != m_EndDate.GetYear()
          ;
    }
コード例 #12
0
ファイル: MyTime.cpp プロジェクト: almondyoung/MyLibOfMySelf
bool CMyCalendar::operator==(CMyCalendar& time)
{
	if(GetYear()==time.GetYear()&&
	   GetMonth()==time.GetMonth()&&
	   GetDay()==time.GetDay())
	   return true;
	return false;
}
コード例 #13
0
ファイル: SpTime.cpp プロジェクト: amikey/tradingstrategyking
DWORD CSPTime::ToStockTimeDay( )
{
	if( -1 == GetTime() || GetTime() < 0 )
		return -1;
	if( 0 == GetTime() )
		return 0;

	return ( GetYear() * 10000 + GetMonth() * 100 + GetDay() );
}
コード例 #14
0
ファイル: KVDatime.cpp プロジェクト: pwigg/kaliveda
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());
}
コード例 #15
0
ファイル: rtc.c プロジェクト: SCUT-Mida/Airpurifier
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();
}
コード例 #16
0
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);
}
コード例 #17
0
ファイル: MyTime.cpp プロジェクト: almondyoung/MyLibOfMySelf
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;
}
コード例 #18
0
ファイル: SpTime.cpp プロジェクト: amikey/tradingstrategyking
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() );
}
コード例 #19
0
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);
}
コード例 #20
0
ファイル: Logger.cpp プロジェクト: Saeyne/Gray
	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();
	}
コード例 #21
0
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);
}
コード例 #22
0
/* 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);
}
コード例 #23
0
ファイル: MyDate.cpp プロジェクト: calebthompson/School
	// 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++;
	}
コード例 #24
0
ファイル: mathstuff.CPP プロジェクト: felixcollins/onstation
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);
	}
}
コード例 #25
0
ファイル: TimeManager.cpp プロジェクト: zhangdongai/Study
tuint32 TimeManager::Time2Day()
{
	tuint32 uRet = 0;

	uRet += GetYear();
	uRet *= 100;

	uRet += GetMonth() + 1;
	uRet *= 100;

	uRet += GetDay();

	return uRet;
}
コード例 #26
0
ファイル: sh_systemtime.cpp プロジェクト: wantao/fullfrog
 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;
 }
コード例 #27
0
ファイル: MyDate.cpp プロジェクト: calebthompson/School
	// 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;
*/
	}
コード例 #28
0
ファイル: funcs.c プロジェクト: bbs-io/mbse
/* 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);
}
コード例 #29
0
ファイル: Func.cpp プロジェクト: slawer/krs_kal
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;
}
コード例 #30
0
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)); */ 
	
};