/*
KEYPOINT) DateTime now = DateTime.ParseExact(MANUAL_DT, "yyyyMMddHHmmss", System.Globalization.CultureInfo.InvariantCulture);
*/
using System;
using System.Timers;
using System.IO;
class Program
{
public static void Main()
{
CHKNMNM nmm = new CHKNMNM();
nmm.CALCCHK();
nmm.REALCHK();
nmm.DISPCHK();
}
}
class CHKNMNM
{
string[] HOLIDAY = new string[]
{
"2024-01-01",
"2024-02-09",
"2024-02-12",
"2024-03-01",
"2024-04-10",
"2024-05-01",
"2024-05-06",
"2024-05-15",
"2024-06-06",
"2024-08-15",
"2024-09-16",
"2024-09-17",
"2024-09-18",
"2024-10-03",
"2024-10-09",
"2024-12-25",
};
string[] HOLIDAYNM = new string[]
{
"2024-01-01(신정)",
"2024-02-09(구정)",
"2024-02-12(구정)",
"2024-03-01(삼일절)",
"2024-04-10(선거일)",
"2024-05-01(노동절)",
"2024-05-06(어린이날대체)",
"2024-05-15(부처님오신날)",
"2024-06-06(현충일)",
"2024-08-15(광복절)",
"2024-09-16(추석)",
"2024-09-17(추석)",
"2024-09-18(추석)",
"2024-10-03(개천절)",
"2024-10-09(한글날)",
"2024-12-25(크리스마스)",
};
string[] YOIL = new string[]
{
"MONDAY",
"TUESDAY",
"WEDNESDAY",
"THURSDAY",
"FRIDAY",
"SATURDAY",
"SUNDAY",
};
string[] RANDOMNM = new string[]
{
"CHO","PARK","JIN",
};
string CHKDateFormat = "yyyy-MM-dd";
const int MAX_CNT = 1024;
string[] CHKNM = new string[MAX_CNT];
string[] CHKDT = new string[MAX_CNT];
string[] CHKYO = new string[MAX_CNT];
string[] CHKRM = new string[MAX_CNT];
string MANUAL_DT = "20230101121212";
public void CALCCHK()
{
int ii = 0; //(1-MON, 7-SUNDAY)
int day = 0;
int mm = 0;
int kk = 0;
DateTime now = DateTime.ParseExact(MANUAL_DT, "yyyyMMddHHmmss", System.Globalization.CultureInfo.InvariantCulture);
DateTime calcnow;
//POINT:CHKRM's INCREASE ITSELF
//POINT:RANDOMNM's INCREASE ITSELF
//POINT:CHKRM's INCREASE ITSELF
//POINT:RANDOMNM's INCREASE ITSELF
while (true)
{
calcnow = now.AddDays(day);
if (Convert.ToInt32(calcnow.ToString(CHKDateFormat).Replace("-", "")) < 20231231)
{
day++;
continue;
}
if (Convert.ToInt32(calcnow.ToString(CHKDateFormat).Replace("-", "")) == 20250101) break;
if (Convert.ToInt32(calcnow.ToString(CHKDateFormat).Replace("-", "")) == 20231231) ii = 7;
int check = 0;
for (int ff = 0; ff < HOLIDAY.Length; ff++)
{
if (calcnow.ToString(CHKDateFormat) == HOLIDAY[ff])
{
check = 100;
break;
}
}
if (check == 0)
{
if (ii == 4) CHKRM[kk++] = RANDOMNM[mm++ % 3];
else if (ii == 5) CHKRM[kk++] = RANDOMNM[mm++ % 3];
}
else
{
if (ii == 1) CHKRM[kk++] = "PARK";
else if (ii == 2) CHKRM[kk++] = "JIN";
else if (ii == 3) CHKRM[kk++] = "CHO";
else if (ii == 4) CHKRM[kk++] = RANDOMNM[mm++ % 3];
else if (ii == 5) CHKRM[kk++] = RANDOMNM[mm++ % 3];
}
day++;
ii++;
if (ii == 8) ii = 1;
}
}
public void REALCHK()
{
int ii = 0; //(1-MON, 7-SUNDAY)
int day = 0;
int kk = 0;
int sum = 0;
DateTime now = DateTime.ParseExact(MANUAL_DT, "yyyyMMddHHmmss", System.Globalization.CultureInfo.InvariantCulture);
DateTime calcnow;
while (true)
{
calcnow = now.AddDays(day);
if (Convert.ToInt32(calcnow.ToString(CHKDateFormat).Replace("-", "")) < 20231231)
{
day++;
continue;
}
if (Convert.ToInt32(calcnow.ToString(CHKDateFormat).Replace("-", "")) == 20250101) break;
if (Convert.ToInt32(calcnow.ToString(CHKDateFormat).Replace("-", "")) == 20231231) ii = 7;
int check = 0;
for (int ff = 0; ff < HOLIDAY.Length; ff++)
{
if (calcnow.ToString(CHKDateFormat) == HOLIDAY[ff])
{
check = 100;
break;
}
}
if (check == 0)
{
if (ii == 1)
{
CHKNM[sum] = "PARK";
CHKYO[sum] = YOIL[ii - 1];
CHKDT[sum] = calcnow.ToString(CHKDateFormat);
}
else if (ii == 2)
{
CHKNM[sum] = "JIN";
CHKYO[sum] = YOIL[ii - 1];
CHKDT[sum] = calcnow.ToString(CHKDateFormat);
}
else if (ii == 3)
{
CHKNM[sum] = "CHO";
CHKYO[sum] = YOIL[ii - 1];
CHKDT[sum] = calcnow.ToString(CHKDateFormat);
}
else if (ii == 4)
{
CHKNM[sum] = CHKRM[kk++];
CHKYO[sum] = YOIL[ii - 1];
CHKDT[sum] = calcnow.ToString(CHKDateFormat);
}
else if (ii == 5)
{
CHKNM[sum] = CHKRM[kk++];
CHKYO[sum] = YOIL[ii - 1];
CHKDT[sum] = calcnow.ToString(CHKDateFormat);
}
else if (ii == 6)
{
CHKNM[sum] = "HOLIDAY";
CHKYO[sum] = YOIL[ii - 1];
CHKDT[sum] = calcnow.ToString(CHKDateFormat);
}
else if (ii == 7)
{
CHKNM[sum] = "HOLIDAY";
CHKYO[sum] = YOIL[ii - 1];
CHKDT[sum] = calcnow.ToString(CHKDateFormat);
}
}
else if (check == 100)
{
CHKYO[sum] = YOIL[ii - 1];
CHKDT[sum] = calcnow.ToString(CHKDateFormat);
int subcheck = 0;
for (int ff = 0; ff < HOLIDAY.Length; ff++)
{
if (CHKDT[sum] == HOLIDAY[ff])
{
CHKNM[sum] = HOLIDAYNM[ff];
subcheck = 100;
break;
}
}
if (subcheck == 0)
{
CHKNM[sum] = "SPECIAL";
}
}
day++;
ii++;
sum++;
if (ii == 8) ii = 1;
}
}
public void DISPCHK()
{
int kk = 0;
int ____park_k = 0, ____jin_k = 0, ____cho_k = 0;
while (true)
{
string dateTxt = "";
string nameTxt = "";
int check = 0;
for (int ii = 0; ii < 7; ii++)
{
dateTxt += CHKDT[kk] + " ";
nameTxt += CHKNM[kk] + " ";
if (CHKNM[kk] == "PARK") ____park_k++;
else if (CHKNM[kk] == "JIN") ____jin_k++;
else if (CHKNM[kk] == "CHO") ____cho_k++;
if (CHKDT[kk] == "2024-12-31")
{
check = 100;
break;
}
kk++;
}
Console.WriteLine(dateTxt);
Console.WriteLine(nameTxt);
if (check == 100) break;
}
}
}