NorwegianHolidaysENJS
Back to ListDescription: Creating a JSON array with Norwegian holidays
FileMaker Prototype:
Set Variable [$res; ACF_Run("NorwegianHolidaysENJS"; 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 NorwegianHolidaysENJS (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 holidays;
end
The NorwegianHolidaysENJS 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.
This function is almost an exact copy of the NorwegianHolidaysEN function, with the exception that it returns JSON type instead of a stringified JSON. When used in other ACF functions, it is best to have pure JSON, and not stringified JSON.
Example
From other ACF functions below.
JSON holidays;
holdays["a"] = NorwegianHolidaysENJS(2024);
This result in the following JSON object:
{ "a":[
{
"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"
}
]
} 