|
#include "DateTime.h"
unsigned char DateTime::m_Day;
unsigned char DateTime::m_Month;
unsigned short DateTime::m_Year;
float DateTime::m_Time;
bool DateTime::m_DayIncreased;
std::wstring DateTime::m_MonthNames[12];
void DateTime::Init(void)
{
m_MonthNames[0] = L"January";
m_MonthNames[1] = L"February";
m_MonthNames[2] = L"March";
m_MonthNames[3] = L"April";
m_MonthNames[4] = L"May";
m_MonthNames[5] = L"June";
m_MonthNames[6] = L"July";
m_MonthNames[7] = L"August";
m_MonthNames[8] = L"September";
m_MonthNames[9] = L"October";
m_MonthNames[10] = L"November";
m_MonthNames[11] = L"December";
};
void DateTime::IncreaseDay(void)
{
m_Day++;
if (m_Day >= 30)
{
m_Day = 1;
m_Month++;
}
if (m_Month >= 12)
{
m_Month = 1;
m_Year++;
}
};
void DateTime::DayToString(std::wstring& _str)
{
char buffer[512];
snprintf(buffer, 512, " --- %d day of ", m_Day);
_str = Utilities::ConvertToUTF8(buffer);
_str += m_MonthNames[m_Month - 1];
snprintf(buffer, 512, " Year %d ---\\ \\", m_Year);
_str += Utilities::ConvertToUTF8(buffer);
};
void DateTime::TimeToString(std::wstring& _str)
{
char buffer[512];
unsigned int totalMinutes = (unsigned int)(m_Time / (float) (m_NightTime + m_DayTime) * m_MinutesInOneDay);
unsigned int hours = (unsigned int)(totalMinutes / (float) 60.0f);
unsigned int minutes = (unsigned int)(totalMinutes - hours * 60.0f);
hours += 6;
if (hours >= 24)
hours -= 24;
snprintf(buffer, 512, " --- Time %02d : %02d ---\\ \\", hours, minutes);
_str = Utilities::ConvertToUTF8(buffer);
};
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.