Festivities of the year

Festivities of the year

Postby Maurizio » Mon May 08, 2023 8: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: 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
User avatar
Maurizio
 
Posts: 824
Joined: Mon Oct 10, 2005 1:29 pm

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 103 guests