ACF Library

NorwegianHolidaysEN

Back to List

Description: Creating a JSON array with Norwegian holidays

FileMaker Prototype:

Set Variable [$res; ACF_Run("NorwegianHolidaysEN"; int_inputYear)]

Category: UTILITY

Dependencies

  • EasterSunday: Calculate the date of the Easter sunday for a given year.

NOTE: This function serves as a reference template. To use it effectively, you may need to adjust certain parts of the code, such as field names, database structures, and specific data lists to fit the requirements of your system. This customization allows the function to work seamlessly within your environment.

Function source:

function NorwegianHolidaysEN (int inputYear)
   string EasterSun = EasterSunday(inputYear); 
   Date dEasterSun = date ( EasterSun);
   string df = "%Y-%m-%d";
   JSON holidays ; 
   holidays["[]"] = JSON ( "name", "New Year's Day", "date", format("%04d-01-01", inputYear));
   holidays["[]"] = JSON ( "name", "Maundy Thursday", "date", string(dEasterSun -3, df));
   holidays["[]"] = JSON ( "name", "Good Friday", "date", string(dEasterSun -2, df));
   holidays["[]"] = JSON ( "name", "Easter Eve", "date", string(dEasterSun -1, df));
   holidays["[]"] = JSON ( "name", "Easter Sunday", "date", string(dEasterSun, df));
   holidays["[]"] = JSON ( "name", "Easter Monday", "date", string(dEasterSun+1, df));
   holidays["[]"] = JSON ( "name", "Labor Day", "date", format("%04d-05-01", inputYear));
   holidays["[]"] = JSON ( "name", "Constitution Day (Norwegian National Day)", "date", format("%04d-05-17", inputYear));
   holidays["[]"] = JSON ( "name", "Ascension Day", "date", string(dEasterSun+39, df));
   holidays["[]"] = JSON ( "name", "Pentecost Eve", "date", string(dEasterSun+48, df));
   holidays["[]"] = JSON ( "name", "Pentecost Sunday", "date", string(dEasterSun+49, df));
   holidays["[]"] = JSON ( "name", "Pentecost Monday", "date", string(dEasterSun+50, df));
   holidays["[]"] = JSON ( "name", "Christmas Eve", "date", format("%04d-12-24", inputYear));
   holidays["[]"] = JSON ( "name", "Christmas Day", "date", format("%04d-12-25", inputYear));
   holidays["[]"] = JSON ( "name", "Boxing Day", "date", format("%04d-12-26", inputYear));
   holidays["[]"] = JSON ( "name", "New Year's Eve", "date", format("%04d-12-31", inputYear));
   
   return string(holidays);
end

The NorwegianHolidaysEN Function are using the EasterSunday function as a base to calculate other Norwegian holidays. You can copy the function and change it to fit your countrys holidays. You must also copy the EasterSunday function and place it above this one.

Example

Set Variable [$res; ACF_Run("NorwegianHolidaysEN"; 2024)]

This result in the following JSON object:

[
    {
        "date": "2024-01-01",
        "name": "New Year's Day"
    },
    {
        "date": "2024-03-28",
        "name": "Maundy Thursday"
    },
    {
        "date": "2024-03-29",
        "name": "Good Friday"
    },
    {
        "date": "2024-03-30",
        "name": "Easter Eve"
    },
    {
        "date": "2024-03-31",
        "name": "Easter Sunday"
    },
    {
        "date": "2024-04-01",
        "name": "Easter Monday"
    },
    {
        "date": "2024-05-01",
        "name": "Labor Day"
    },
    {
        "date": "2024-05-17",
        "name": "Constitution Day (Norwegian National Day)"
    },
    {
        "date": "2024-05-09",
        "name": "Ascension Day"
    },
    {
        "date": "2024-05-18",
        "name": "Pentecost Eve"
    },
    {
        "date": "2024-05-19",
        "name": "Pentecost Sunday"
    },
    {
        "date": "2024-05-20",
        "name": "Pentecost Monday"
    },
    {
        "date": "2024-12-24",
        "name": "Christmas Eve"
    },
    {
        "date": "2024-12-25",
        "name": "Christmas Day"
    },
    {
        "date": "2024-12-26",
        "name": "Boxing Day"
    },
    {
        "date": "2024-12-31",
        "name": "New Year's Eve"
    }
]

Version with Norwegian names

function NorwegianHolidaysNO (int inputyear)
    string EasterSun = EasterSunday(inputYear); 
    Date dEasterSun = date ( EasterSun);
    string df = "%Y-%m-%d";
    JSON holidays ; 
    holidays["[]"] = JSON ( "name", "1. Nyttårsdag", "date", format("%04d-01-01", inputYear));
    holidays["[]"] = JSON ( "name", "Skjærtorsdag", "date", string(dEasterSun -3, df));
    holidays["[]"] = JSON ( "name", "Langfredag", "date", string(dEasterSun -2, df));
    holidays["[]"] = JSON ( "name", "Påskeaften", "date", string(dEasterSun -1, df));
    holidays["[]"] = JSON ( "name", "1.Påskedag", "date", string(dEasterSun, df));
    holidays["[]"] = JSON ( "name", "2.Påskedag", "date", string(dEasterSun+1, df));
    holidays["[]"] = JSON ( "name", "1. Mai", "date", format("%04d-05-01", inputYear));
    holidays["[]"] = JSON ( "name", "17. Mai (norsk nasjonaldag)", "date", format("%04d-05-17", inputYear));
    holidays["[]"] = JSON ( "name", "Kristi Himmelfartsdag", "date", string(dEasterSun+39, df));
    holidays["[]"] = JSON ( "name", "Pinseaften", "date", string(dEasterSun+48, df));
    holidays["[]"] = JSON ( "name", "1.Pinsedag", "date", string(dEasterSun+49, df));
    holidays["[]"] = JSON ( "name", "2.Pinsedag", "date", string(dEasterSun+50, df));
    holidays["[]"] = JSON ( "name", "Juleaften", "date", format("%04d-12-24", inputYear));
    holidays["[]"] = JSON ( "name", "1.juledag", "date", format("%04d-12-25", inputYear));
    holidays["[]"] = JSON ( "name", "2.juledag", "date", format("%04d-12-26", inputYear));
    holidays["[]"] = JSON ( "name", "Nyttårsaften", "date", format("%04d-12-31", inputYear));

    return string(holidays);
end
Back to List