FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Festivities of the year
Posts: 842
Joined: Mon Oct 10, 2005 01:29 PM
Festivities of the year
Posted: Mon May 08, 2023 08:33 AM
Hello Antonio ,
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 (fw): Select all Collapse
#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

Continue the discussion