Exemplo n.º 1
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;
}
Exemplo n.º 2
0
int GetFirstDOW() {
	int dow=GetDayOfWeek()-(GetDayOfYear() % 7)+21;
	
	while (dow>6) dow-=7;
	return dow;
}