Beispiel #1
0
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;
}
Beispiel #2
0
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;
}
Beispiel #3
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 "";
}
Beispiel #4
0
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;
}
Beispiel #5
0
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";
}
Beispiel #6
0
void MyMusicTreeModel::GetValue( wxVariant &variant,
                                 const wxDataViewItem &item, unsigned int col ) const
{
    wxASSERT(item.IsOk());

    MyMusicTreeModelNode *node = (MyMusicTreeModelNode*) item.GetID();
    switch (col)
    {
    case 0:
        variant = node->m_title;
        break;
    case 1:
        variant = node->m_artist;
        break;
    case 2:
        variant = (long) node->m_year;
        break;
    case 3:
        variant = node->m_quality;
        break;
    case 4:
        variant = 80L;  // all music is very 80% popular
        break;
    case 5:
        if (GetYear(item) < 1900)
            variant = "old";
        else
            variant = "new";
        break;

    default:
        wxLogError( "MyMusicTreeModel::GetValue: wrong column %d", col );
    }
}
Beispiel #7
0
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 ;
}
Beispiel #8
0
 bool HasEndDate(void) const
    {
       return GetDay() != m_EndDate.GetDay()
          || GetMonth() != m_EndDate.GetMonth()
          || GetYear() != m_EndDate.GetYear()
          ;
    }
Beispiel #9
0
bool CMyCalendar::operator==(CMyCalendar& time)
{
	if(GetYear()==time.GetYear()&&
	   GetMonth()==time.GetMonth()&&
	   GetDay()==time.GetDay())
	   return true;
	return false;
}
Beispiel #10
0
 bool CDateTime::_CheckYearIsRight()
 {
     UINT32 year = GetYear();
     if (year >= 1970 && year <= 2037) {
         return true;
     }
     return false;
 }
Beispiel #11
0
DWORD CSPTime::ToStockTimeDay( )
{
	if( -1 == GetTime() || GetTime() < 0 )
		return -1;
	if( 0 == GetTime() )
		return 0;

	return ( GetYear() * 10000 + GetMonth() * 100 + GetDay() );
}
Beispiel #12
0
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());
}
Beispiel #13
0
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();
}
Beispiel #14
0
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;
}
Beispiel #15
0
	// SetYear
		// sets the year of the current date
	void MyDate::SetYear(int newYear) {
		int year = GetYear();
		// remove old years
		_days = _days - (year * 365);
		_days = _days - (this->GetLeapYears(year));

		// add new years
		_days = _days + newYear * 365;
		_days = _days + GetLeapYears(newYear);
	}
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);
}
Beispiel #17
0
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() );
}
Beispiel #18
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);
}
Beispiel #19
0
	// 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++;
	}
Beispiel #20
0
FString FDateTime::ToString( const TCHAR* Format ) const
{
	FString Result;

	if (Format != nullptr)
	{
		while (*Format != TCHAR('\0'))
		{
			if ((*Format == TCHAR('%')) && (*(++Format) != TCHAR('\0')))
			{
				switch (*Format)
				{
				case TCHAR('a'): Result += IsMorning() ? TEXT("am") : TEXT("pm"); break;
				case TCHAR('A'): Result += IsMorning() ? TEXT("AM") : TEXT("PM"); break;
				case TCHAR('d'): Result += FString::Printf(TEXT("%02i"), GetDay()); break;
				case TCHAR('D'): Result += FString::Printf(TEXT("%03i"), GetDayOfYear()); break;
				case TCHAR('m'): Result += FString::Printf(TEXT("%02i"), GetMonth()); break;
				case TCHAR('y'): Result += FString::Printf(TEXT("%02i"), GetYear() % 100); break;
				case TCHAR('Y'): Result += FString::Printf(TEXT("%04i"), GetYear()); break;
				case TCHAR('h'): Result += FString::Printf(TEXT("%02i"), GetHour12()); break;
				case TCHAR('H'): Result += FString::Printf(TEXT("%02i"), GetHour()); break;
				case TCHAR('M'): Result += FString::Printf(TEXT("%02i"), GetMinute()); break;
				case TCHAR('S'): Result += FString::Printf(TEXT("%02i"), GetSecond()); break;
				case TCHAR('s'): Result += FString::Printf(TEXT("%03i"), GetMillisecond()); break;
				default:		 Result += *Format;
				}
			}
			else
			{
				Result += *Format;
			}

			// move to the next one
			Format++;
		}
	}

	return Result;
}
Beispiel #21
0
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);
	}
}
Beispiel #22
0
tuint32 TimeManager::Time2Day()
{
	tuint32 uRet = 0;

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

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

	uRet += GetDay();

	return uRet;
}
Beispiel #23
0
	// 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;
*/
	}
Beispiel #24
0
 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;
 }
Beispiel #25
0
inline string _date_::ToStdString() const {
	string convertita = "";
	ostringstream out;
	out.fill('0');
	out.width(2);
	out << GetYear();
	out.width(1);
	out	<< '-';
	out.fill('0');
	out.width(2);
	out	<< GetMonth();
	out.width(1);
	out	<< '-';
	out.fill('0');
	out.width(2);
	out	<< GetDay();
	convertita = out.str();
	return convertita;
}
Beispiel #26
0
// negative values mean day/month/year/hour/minute is in the past
int	MinutesBefore(int day, int month, int year, int hour, int minute) {
	int	td=GetDay(),
		tm=GetMonth(),
		ty=GetYear(),
		th=GetHour(),
		tmin=GetMinute();
		
	int32	m1, m2;
	
	m1=(int32)GetDaysFrom1984To(td, tm, ty)*24*60;
	m1+=th*60+tmin;
	// m1: minutes since 01/01/1984 (until now).
	
	m2=(int32)GetDaysFrom1984To(day, month, year)*24*60;
	m2+=hour*60+minute;
	// m2: minutes since 01/01/1984 until month/day/year.
	
	return m2-m1;	
}
Beispiel #27
0
void HomeScreen::render()
{
    uint16_t schcolor = color565(142,35,35); //red
    uint16_t setcolor = color565(35, 142, 35); // green
	uint16_t devcolor = color565(205,173,0); // yellow
	uint16_t stacolor = color565(51,153,204); //blue
	fillScreen(BLACK);
	makeRectangle(10,10,90,140,WHITE, 2);
	makeRectangle(15,15,90,140,setcolor, 4);
	//makeRectangle(15,15,90,140,MAGENTA, 3);
	makeRectangle(10,160,90,140, WHITE, 2);
	makeRectangle(15,165,90,140,devcolor,4);
	//makeRectangle(15,165,90,140, BLACK, 3);
	makeRectangle(110,10, 90, 140, WHITE, 2);
	makeRectangle(115,15,90,140, schcolor,4);
	//makeRectangle(115,15, 90, 140, BLACK, 3);
	makeRectangle(110,160, 90, 140, WHITE, 2);
	makeRectangle(115,165, 90, 140, stacolor, 4);
	//makeRectangle(115,165, 90, 140, MAGENTA, 3);

	char * home = "HOME";
	char * set = "Settings";
	char * sched = "Schedule";
	char * dev = "Devices";
	char * stats = "Status";
	char buf[]= "00/00/00";
	twodigit(buf, GetMonth(),false);
	twodigit(buf+3, GetDate(), false);
	twodigit(buf+6, GetYear(), false);



	drawString(215,120 , home, WHITE, BLACK, 3);
	drawString(55,35, set, WHITE, BLACK, 2);
	drawString(155,35, dev, WHITE, BLACK, 2);
	drawString(55, 180, sched, WHITE, BLACK, 2);
	drawString(155,200, stats, WHITE, BLACK,  2);

	drawString(224, 1 , buf, WHITE, BLACK, 2);

    renderTime();
}
Beispiel #28
0
//例如:20070403表示2007年4月3日
UINT TimeManager::Time2Day( )
{
	__ENTER_FUNCTION

		UINT uRet=0 ;

	uRet += GetYear( ) ;

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

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

	return uRet ;

	__LEAVE_FUNCTION

		return 0 ;
}
Beispiel #29
0
int main()
{
	time_t timer = GetCurrentTime();
	printf("timer = %ld \n", timer);
	printf("%s", asctime(localtime(&timer)));
	printf("day = %d \n", GetDay(timer));
	printf("month = %d \n", GetMonth(timer));
	printf("year = %d \n", GetYear(timer));
	struct tm *p_tm = localtime(&timer);
	ULONG timm = GetTimeByYMDHMS(p_tm->tm_year + 1900, p_tm->tm_mon + 1,p_tm->tm_mday, 
							p_tm->tm_hour,p_tm->tm_min,p_tm->tm_sec);
		printf("1ptm = %ld\n", timm);
	char tmp[50];
	
	TimeFormat(timer, "Y-*M-D:H-M)S", tmp, 21);
	
	printf("tmp  = %s\n", tmp);
	printf("Getptm = %ld\n", GetTimeByString("[email protected]"));
	return 0;
}
Beispiel #30
0
 CDateTime & CDateTime::DecMonth(UINT32 month)
 {
     for (UINT32 i = 1; i <= month; i++) {
         m_time.tm_mon -= 1;
         if (m_time.tm_mon < 0) {
             m_time.tm_mon = 11;
             m_time.tm_year -= 1;
         }
     }
     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;
 }