#include "MenuTextDate.h"

void MenuTextDate::Step()
{
	if (bOnce)
	{
		bOnce = false;
		char buff[10];
		ZeroMemory(&buff, sizeof(buff));
		strncpy_s(buff, __DATE__, 3);
		int month = 0;
		if (!strcmp(buff, "Jan"))
			month = 1;
		else if(!strcmp(buff, "Feb"))
			month = 2;
		else if (!strcmp(buff, "Mar"))
			month = 3;
		else if (!strcmp(buff, "Apr"))
			month = 4;
		else if (!strcmp(buff, "May"))
			month = 5;
		else if (!strcmp(buff, "Jun"))
			month = 6;
		else if (!strcmp(buff, "Jul"))
			month = 7;
		else if (!strcmp(buff, "Aug"))
			month = 8;
		else if (!strcmp(buff, "Sep"))
			month = 9;
		else if (!strcmp(buff, "Oct"))
			month = 10;
		else if (!strcmp(buff, "Nov"))
			month = 11;
		else if (!strcmp(buff, "Dec"))
			month = 12;

		int day;
		ZeroMemory(&buff, sizeof(buff));
		strncpy_s(buff, __DATE__ + 4, 2);
		sscanf_s(buff, "%d", &day);

		int year;
		ZeroMemory(&buff, sizeof(buff));
		strncpy_s(buff, __DATE__ + 7, 4);
		sscanf_s(buff, "%d", &year);
		wchar_t wbuff[20];
		swprintf_s(wbuff, L"%d-%d-%d", year, month, day);
		el.eid = wbuff;
	}
}

std::shared_ptr<Entity> CreateMenuTextDate()
{
	return std::make_shared<MenuTextDate>();
}
