I'm looking for a function that tells me if a day is a public holiday or not, (not just Saturday and Sunday)
from the windows calendar .
I found this function , is it possible to adapt it in fivewin ?
- Code: Select all Expand view
- #include <windows.h>
int main()
{
SYSTEMTIME st = { 2023, 8, 5 };
CALID calid = CAL_GREGORIAN;
LCID lcid = LOCALE_USER_DEFAULT;
CALTYPE caltype = CAL_ITWODIGITYEARMAX | CAL_RETURN_NUMBER;
int result = 0;
// Get the list of holidays for the given calendar
int count = GetCalendarInfo(lcid, calid, caltype, NULL, 0, &result);
// Check if the current date is a holiday
if (count > 0)
{
int* holidays = new int[count];
GetCalendarInfo(lcid, calid, caltype, (LPTSTR)holidays, count, &result);
for (int i = 0; i < count; i++)
{
if (st.wDay == holidays[i])
{
printf("The current date is a holiday\n");
break;
}
}
delete[] holidays;
}
return 0;
}
Regards Maurizio