int Time::TimeCheck(Time time){ /*1 jika this sebelum time, -1 jika this sesudah time, 0 jika this sama dengan time*/
	if (GetHour() < time.GetHour()){
		return 1;
	}
	else if (GetHour() > time.GetHour()){
		return -1;
	}
	else {/*Tahun sama*/
		if (GetMinute() < time.GetMinute()){
			return 1;
		}
		else if (GetMinute() > time.GetMinute()){
			return -1;
		}
		else{/*Tahun dan bulan sama*/
			if (GetSecond() < time.GetSecond()){
				return 1;
			}
			else if (GetSecond() > time.GetSecond()){
				return -1;
			}
			else{/*Tahun dan bulan dan hari sama*/
				return 0;
			}
		}
	}
}
Exemple #2
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;
}
Exemple #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 "";
}
Exemple #4
0
bool Time::operator<(const Time &t2) const {
  if ((GetHour() == t2.GetHour()) &&
      (GetMinute() == t2.GetMinute()) &&
      (GetSecond() < t2.GetSecond()))
    return true;
  else if ((GetHour() == t2.GetHour()) &&
      (GetMinute() < t2.GetMinute()))
    return true;
  else if ((GetHour() < t2.GetHour()))
    return true;

  return false;
}
Exemple #5
0
void HomeScreen::loop()
{
    uint8_t theTime = 4*GetHour() + GetMinute();
    if(theTime != displayedTime) {
        renderTime();
    }

    int x = getTouchX();
    int y = getTouchY();

    if (x > 10 && x<105 && y>10 && y < 155)
    {
        manager.presentScreen(settingsScreen);
    }
    else if (y> 160 && y<305 && x>10 && x<105)
    {
        manager.presentScreen(schedulePickDeviceScreen);
    }
    else if (x>110 && x<205 &&y>10 && y<155)
    {
        manager.presentScreen(deviceScreen);
    }
    else if (x>110 && x<205 && y>160 && y<305)
    {
        manager.presentScreen(statusScreen);
    }

    sleep(100);
}
Exemple #6
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";
}
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 ;
}
Exemple #8
0
int CheckEnable(void)
{
	int ActionId;
	int x;
	
	for(ActionId=0; ActionId<NoOfActions; ActionId++)
	{
		if( TimedActions[ActionId].InProgress == 0 )
		{
			if( !strcmp(TimedActions[ActionId].Active, "true") )
			{
				if( atoi(TimedActions[ActionId].Hour) == GetHour() )
				{
					if( atoi(TimedActions[ActionId].Minute) == GetMinute() )
					{
						for(x=0; x<7; x++)
						{
							if( CheckDayOfWeek(TimedActions[ActionId].DaysToWork[x]) )
							{
								TimedActions[ActionId].InProgress = 1;
								printf("------------------------------------------\r\n");
								printf("Action \"%s\" [%i] started\r\n", TimedActions[ActionId].Name, ActionId);
								printf("------------------------------------------\r\n");
								return ActionId;
							}
						}

					}
				}
			}
		}
	}
	
	return -1;
}
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;
}
Exemple #10
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();
}
Exemple #11
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());
}
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);
}
Exemple #13
0
MString MTimeSpan::GetString(bool msec/* = true*/) const
{
    TCHAR sz[256];
    if (msec)
    {
        if (GetTotalDays() > 0)
        {
            ::wsprintf(sz, TEXT("%u days and %02u:%02u:%02u.%03u"),
                static_cast<UINT>(GetTotalDays()),
                static_cast<UINT>(GetHour()),
                static_cast<UINT>(GetMinute()),
                static_cast<UINT>(GetSecond()),
                static_cast<UINT>(GetMilliseconds()));
        }
        else
        {
            ::wsprintf(sz, TEXT("%02u:%02u:%02u.%03u"),
                static_cast<UINT>(GetHour()),
                static_cast<UINT>(GetMinute()),
                static_cast<UINT>(GetSecond()),
                static_cast<UINT>(GetMilliseconds()));
        }
    }
    else
    {
        if (GetTotalDays() > 0)
        {
            ::wsprintf(sz, TEXT("%u days and %02u:%02u:%02u"),
                static_cast<UINT>(GetTotalDays()),
                static_cast<UINT>(GetHour()),
                static_cast<UINT>(GetMinute()),
                static_cast<UINT>(GetSecond()));
        }
        else
        {
            ::wsprintf(sz, TEXT("%02u:%02u:%02u"),
                static_cast<UINT>(GetHour()),
                static_cast<UINT>(GetMinute()),
                static_cast<UINT>(GetSecond()));
        }
    }
    return MString(sz);
}
Exemple #14
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() );
}
Exemple #15
0
void setLastModifTime(directory_entry* e, JAM J){
	//asumsi disimpan dalam big endian
	//TODO tanyakan lagi
	
	uint16_t word = (GetHour(J)<<11) | (GetMinute(J)<<5) | (GetSecond(J)/2);

	e->bytearr[0x16] = (word&0xff00) >> 8;
	e->bytearr[0x17] = (word&0x00ff);
	
	return;
}
Exemple #16
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);
}
Exemple #17
0
void HomeScreen::renderTime()
{
    uint8_t hour = GetHour();
    uint8_t minute = GetMinute();
    displayedTime = 4*hour + minute;

    char tim[] = "00:00 PM";
    twodigit(tim, hour, false);
    twodigit(tim+3, minute, false);
    if (GetAmPm() == 0)
    {
        tim[6] = 'A';
    }

    drawString(225, 220, tim, WHITE, BLACK, 2);
}
Exemple #18
0
Time Time::operator-(long seconds) const {
  int hour = 0, minute = 0, second = 0;
  long time_in_seconds = GetHour() * 60 * 60 + GetMinute() * 60 + GetSecond() - seconds;

  if (time_in_seconds > 0) {
    hour = time_in_seconds / (60 * 60);
    time_in_seconds = time_in_seconds - hour * (60 * 60);

    minute = time_in_seconds / 60;
    time_in_seconds = time_in_seconds - minute * 60;

    second = time_in_seconds;
  }

  return Time::Create(hour, minute, second);
}
Exemple #19
0
Time Time::operator+(long seconds) const {
  int hour = 23, minute = 59, second = 59;

  if (seconds < 23 * 60 * 60 + 59 * 60 + 59) {
    long time_in_seconds = GetHour() * 60 * 60 + GetMinute() * 60 + GetSecond() + seconds;

    if (time_in_seconds < 23 * 60 * 60 + 59 * 60 + 59) {
      hour = time_in_seconds / (60 * 60);
      time_in_seconds = time_in_seconds - hour * (60 * 60);

      minute = time_in_seconds / 60;
      time_in_seconds = time_in_seconds - minute * 60;

      second = time_in_seconds;
    }
  }

  return Time::Create(hour, minute, second);
}
Exemple #20
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;	
}
Exemple #21
0
tuint32 TimeManager::Time2DWORD()
{
	tuint32 uRet = 0;

	uRet += GetYear();
	uRet -= 2000;	//从2000年开始计算
	uRet *= 100;	//左移两位

	uRet += GetMonth() + 1;//月份要从1开始表示
	uRet *= 100;	//左移两位 

	uRet += GetDay();
	uRet *= 100;//左移两位

	uRet += GetHour();
	uRet *= 100;	//左移两位

	uRet += GetMinute();

	return uRet;
}
Exemple #22
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;
}
CString CSonTime::get_partV(char b)
{
	CString c;
	char a[255];
	int i;

	switch (b)
	{
	case 'A':
		{
			i = GetDayOfWeek();
			switch (i)
			{
				case 1:
					c = "Sunday";
					break;
				case 4:
					c.Format("%s %s","wday",unit_arr[15]);
					break;
				default:
					{
						c.Format("%s",m_pfnV(_itoa(i,a,10)));
						c = c.Right(c.GetLength()-3); 
						c = "wday " + c;
					}
			}			
		}
			break;
	case 'B':
		{
			i = GetMonth();
			switch (i)
			{
				case 4:
					c.Format("%s %s","month",unit_arr[15]);
					break;
				default:
					{
						c.Format("%s",m_pfnV(_itoa(i,a,10)));
						c = c.Right(c.GetLength()-3); 
						c = "month " + c;
					}
			}			
		}
			break;
	case 'd':
		{
			i = GetDay();
			c.Format("%s",m_pfnV(_itoa(i,a,10)));
			c = c.Right(c.GetLength()-3); 
			if (i<11)
				c = "day mg " + c;
			else
				c = "day " + c;			
		}
			break;
	case 'H':
		{	
			c.Format("%s hour",m_pfnV(_itoa(GetHour(),a,10)));
			c = c.Right(c.GetLength()-3); 
		}
			break;
	case 'M':
		{	
			c.Format("%s minute",m_pfnV(_itoa(GetMinute(),a,10)));
			c = c.Right(c.GetLength()-3) ;
		}
			break;
	case 'S':
		{	
			c.Format("%s second",m_pfnV(_itoa(GetSecond(),a,10)));
			c = c.Right(c.GetLength()-3) ;
		}			
			break;
	case 'y':
		{	
			c.Format("%s",m_pfnV(_itoa(GetYear()%100,a,10)));
			c = c.Right(c.GetLength()-3) ;
			c = "year " + c;
		}
			break;
	case 'Y':
		{	
			c.Format("%s",m_pfnV(_itoa(GetYear(),a,10)));
			c = c.Right(c.GetLength()-3) ;
			c = "year " + c;
		}
			break;
	default:
			c = b;
	}
	return c;	
}
CString CSonTime::get_partE(char b)
{
	CString c;
	char a[255];
	int i;
	funcptr pOE = &VS_OrdinalE;
	funcptr pCE = &VS_CardinalE;

	switch (b)
	{
	case 'A':
		{
			c = Format("%A");
		}
			break;
	case 'B':
		{
			c = Format("%B");			
		}
			break;
	case 'd':
		{
			i = GetDay();
			c.Format("%s",pOE(_itoa(i,a,10)));
			c = c.Right(c.GetLength()-3); 			
			c = "the " + c;
		}
			break;

	case 'H':
		{	
			c.Format("%s",pCE(_itoa(GetHour(),a,10)));
			c = c.Right(c.GetLength()-3); 
		}
			break;
	case 'M':
		{	
			c.Format("%s",pCE(_itoa(GetMinute(),a,10)));
			c = c.Right(c.GetLength()-3) ;
		}
			break;
	case 'S':
		{	
			c.Format("%s second",pCE(_itoa(GetSecond(),a,10)));
			c = c.Right(c.GetLength()-3) ;
		}			
			break;
	case 'y':
		{	
			c.Format("%s",pCE(_itoa(GetYear()%100,a,10)));
			c = c.Right(c.GetLength()-3) ;			
		}
			break;
	case 'Y':
		{	
			if ( (i = GetYear()) < 2000)
			{
				CString c1;
				
				c.Format("%s",pCE(_itoa(i/100,a,10)));
				c = c.Right(c.GetLength()-3) ;			

				
				c1.Format("%s",pCE(_itoa(i%100,a,10)));
				c1 = c1.Right(c1.GetLength()-3) ;			

				c = c + " " + c1;
			}
			else
			{
				c.Format("%s",pCE(_itoa(i,a,10)));
				c = c.Right(c.GetLength()-3) ;	
			}
		}
			break;
	default:
			c = b;
	}
	return c;
}
Exemple #25
0
CDate::ECompare CDate_std::Compare(const CDate_std& date) const
{
    if (GetYear() < date.GetYear()) {
        return CDate::eCompare_before;
    } else if (GetYear() > date.GetYear()) {
        return CDate::eCompare_after;
    }

    if ((CanGetSeason()  ||  date.CanGetSeason())
        && ( !CanGetSeason()  ||  !date.CanGetSeason()
            || GetSeason()  !=  date.GetSeason())) {
        return CDate::eCompare_unknown;
    }

    if (CanGetMonth()  ||  date.CanGetMonth()) {
        if ( !CanGetMonth()  ||  !date.CanGetMonth()) {
            return CDate::eCompare_unknown;
        } else if (GetMonth() < date.GetMonth()) {
            return CDate::eCompare_before;
        } else if (GetMonth() > date.GetMonth()) {
            return CDate::eCompare_after;
        }
    }

    if (CanGetDay()  ||  date.CanGetDay()) {
        if ( !CanGetDay()  ||  !date.CanGetDay()) {
            return CDate::eCompare_unknown;
        } else if (GetDay() < date.GetDay()) {
            return CDate::eCompare_before;
        } else if (GetDay() > date.GetDay()) {
            return CDate::eCompare_after;
        }
    }

    if (CanGetHour()  ||  date.CanGetHour()) {
        if ( !CanGetHour()  ||  !date.CanGetHour()) {
            return CDate::eCompare_unknown;
        } else if (GetHour() < date.GetHour()) {
            return CDate::eCompare_before;
        } else if (GetHour() > date.GetHour()) {
            return CDate::eCompare_after;
        }
    }

    if (CanGetMinute()  ||  date.CanGetMinute()) {
        if ( !CanGetMinute()  ||  !date.CanGetMinute()) {
            return CDate::eCompare_unknown;
        } else if (GetMinute() < date.GetMinute()) {
            return CDate::eCompare_before;
        } else if (GetMinute() > date.GetMinute()) {
            return CDate::eCompare_after;
        }
    }

    if (CanGetSecond()  ||  date.CanGetSecond()) {
        if ( !CanGetSecond()  ||  !date.CanGetSecond()) {
            return CDate::eCompare_unknown;
        } else if (GetSecond() < date.GetSecond()) {
            return CDate::eCompare_before;
        } else if (GetSecond() > date.GetSecond()) {
            return CDate::eCompare_after;
        }
    }

    return CDate::eCompare_same;
}
Exemple #26
0
void CDate_std::GetDate(string* label, const string& format) const
{
    static const char* const kMonths[] = {
        "0", "January", "February", "March", "April", "May", "June",
        "July", "August", "September", "October", "November", "December"
    };
    static const int kNumMonths = sizeof (kMonths) / sizeof (char*);

    if (!label) {
        return;
    }
    unsigned int                        depth = 0;
    vector<pair<SIZE_TYPE, SIZE_TYPE> > starts;
    starts.push_back(make_pair(label->size(), (SIZE_TYPE)0));
    ITERATE (string, it, format) {
        if (*it != '%') {
            *label += *it;
            continue;
        }
        if (++it == format.end()) {
            NCBI_THROW2(CGeneralParseException, eFormat,
                        "CDate_std::GetDate(): incomplete % expression",
                        it - format.begin());
        }
        // Check for things that can only immediately follow %
        if (*it == '%') {
            *label += '%';
            continue;
        }
        else if (*it == '{') {
            depth++;
            starts.push_back(make_pair(label->size(),
                                       SIZE_TYPE(it - format.begin())));
            continue;
        } else if (*it == '}') {
            if (depth == 0) {
                NCBI_THROW2(CGeneralParseException, eFormat,
                            "CDate_std::GetDate(): unbalanced %}",
                            it - format.begin());
            }
            depth--;
            starts.pop_back();
            continue;
        } else if (*it == '|') {
            // We survived, so just look for the appropriate %}.
            if (depth == 0) {
                return; // Can ignore rest of format
            }
            unsigned int depth2 = 0;
            for (;;) {
                while (++it != format.end()  &&  *it != '%')
                    ;
                if (it == format.end()  ||  ++it == format.end()) {
                    NCBI_THROW2(CGeneralParseException, eFormat,
                                "CDate_std::GetDate(): unbalanced %{",
                                starts.back().second);
                }
                if (*it == '}') {
                    if (depth2 == 0) {
                        depth--;
                        starts.pop_back();
                        break;
                    } else {
                        depth2--;
                    }
                } else if (*it == '{') {
                    depth2++;
                }
            }
            continue;
        }

        unsigned int length = 0;
        int          value  = -1;
        while (isdigit((unsigned char)(*it))) {
            length = length * 10 + *it - '0';
            if (++it == format.end()) {
                NCBI_THROW2(CGeneralParseException, eFormat,
                            "CDate_std::GetDate(): incomplete % expression",
                            it - format.begin());
            }
        }
        switch (*it) {
        case 'Y': value = GetYear(); break;
        case 'M':
        case 'N': value = CanGetMonth()  ? GetMonth()  : -1; break;
        case 'D': value = CanGetDay()    ? GetDay()    : -1; break;
        case 'S': value = CanGetSeason() ? 1           : -1; break;
        case 'h': value = CanGetHour()   ? GetHour()   : -1; break;
        case 'm': value = CanGetMinute() ? GetMinute() : -1; break;
        case 's': value = CanGetSecond() ? GetSecond() : -1; break;
        default:
            NCBI_THROW2(CGeneralParseException, eFormat,
                        "CDate_std::GetDate(): unrecognized format specifier",
                        it - format.begin());
        }

        if (value >= 0) {
            if (*it == 'N') { // special cases
                const char* name;
                if (value >= kNumMonths) {
                    name = "inv";
                } else {
                    name = kMonths[value];
                }
                if (length > 0) {
                    label->append(name, length);
                } else {
                    *label += name;
                }
            } else if (*it == 'S') {
                if (length > 0) {
                    label->append(GetSeason(), 0, length);
                } else {
                    *label += GetSeason();
                }
            } else { // just a number
                if (length > 0) {
                    // We want exactly <length> digits.
                    CNcbiOstrstream oss;
                    oss << setfill('0') << setw(length) << value;
                    string s = CNcbiOstrstreamToString(oss);
                    label->append(s, s.size() > length ? s.size() - length : 0,
                                  length);
                } else {
                    *label += NStr::IntToString(value);
                }
            }
        } else {
            // missing...roll back label and look for alternatives, or
            // throw if at top level and none found
            label->erase(starts.back().first);
            char         request = *it;
            unsigned int depth2  = 0;
            for (;;) {
                while (++it != format.end()  &&  *it != '%')
                    ;
                if (it == format.end()  ||  ++it == format.end()) {
                    if (depth > 0  ||  depth2 > 0) {
                        NCBI_THROW2(CGeneralParseException, eFormat,
                                    "CDate_std::GetDate(): unbalanced %{",
                                    starts.back().second);
                    } else {
                        NCBI_THROW2(CGeneralParseException, eFormat,
                                   string("CDate_std::GetDate():"
                                          " missing required field %")
                                   + request, it - format.begin() - 1);
                    }
                }
                if (*it == '|'  &&  depth2 == 0) {
                    break;
                } else if (*it == '}') {
                    if (depth2 == 0) {
                        if (depth == 0) {
                            NCBI_THROW2(CGeneralParseException, eFormat,
                                        "CDate_std::GetDate(): unbalanced %}",
                                        it - format.begin());
                        }
                        depth--;
                        starts.pop_back();
                        break;
                    } else {
                        depth2--;
                    }
                } else if (*it == '{') {
                    depth2++;
                }
            }
        }
    }
}
Exemple #27
0
void SettingsSetTimeScreen::loop()
{
    return;
    int x = getTouchX();
    int y = getTouchY();

    // TODO
    if (x>54 && x<88) {
        //-
        if (y>6 && y<27) {
            // month
            uint8_t month = GetMonth();
            uint8_t next_month = month - 1;
            if(month == 0)
                next_month = 12;

            SetMonth(next_month);
            renderMonth();
        }
        if (y>40 && y<61) {
            // day
            uint8_t day = GetDate();
            uint8_t next_day = day - 1;
            if(day == 0)
                next_day = 31;

            SetMonth(next_day);
            renderDay();
        }
        if (y>73 && y<94) {
            // yr
            uint8_t year = GetYear();
            uint8_t next_year = year - 1;
            SetYear(next_year);
            renderYear();
        }
        if (y>106 && y<127) {
            // hr
            uint8_t hour = GetHour();
            uint8_t next_hour = hour - 1;
            SetHour(next_hour);
            renderHour();
        }
        if (y>140 && y<161) {
            // min
            uint8_t minute = GetMinute();
            uint8_t next_minute = minute - 1;
            SetMinute(next_minute);
            renderMinute();
        }
        if (y>173 && y<194) {
            // am/pm
            uint8_t ampm = GetAmPm();
            SetAmPm(~ampm);
        }

    }
    if (x>104 && x<138) {
        //+
        if (y>6 && y<27) {
            // month
        }
        if (y>40 && y<61) {
            // day
        }
        if (y>73 && y<94) {
            // yr
        }
        if (y>106 && y<127) {
            // hr
        }
        if (y>140 && y<161) {
            // min
        }
        if (y>173 && y<194) {
            // am/pm
        }
    }
}
Exemple #28
0
void SettingsSetTimeScreen::renderMinute()
{
    // numToStr(GetMinute());
	twodigit(buf, GetMinute());
    drawString(110, 228, buf, WHITE, BLACK, 2);
}
Exemple #29
0
bool Time::operator==(const Time &t2) const {
  return (GetHour() == t2.GetHour()) &&
      (GetMinute() == t2.GetMinute()) &&
      (GetSecond() == t2.GetSecond());
}
//! Time formatted like 11:27
std::string TimeStamp::GetTime(void)
{
	return StringBuilder() + GetHour() + ":" + GetMinute();
}