0

As Title states with the help of sapui5 functionality, a way to find out all the holidays in Europe Germany and add those as special Dates in the Calendar.

I looked up the methodologies, the Calender function, doesnt seem to have an method of finding out Holidays. There is also a possibility, to check if a certain date is a holiday, however with the set of Date from 1970 to present it will take a giga While to check all the dates and find wether or not the given Date is indeed a holiday or not.

1 Answers1

0

I have found an Holiday API to get the Public holidays by providing the following parameters like region, country, dates etc hope it will help you.

XML view

<l:VerticalLayout> 
    <l:content>
       <u:Calendar
        id="calendar"
        months="1"
        specialDates="{path: '/germalSplDts'}"                    
        singleSelection="false" >
          <u:specialDates>
            <u:DateTypeRange 
                startDate="{parts: ['date/day', 'date/month', 'date/year'], formatter:'assets.util.mFormatter.formatCalDate'}"
                type="Type09" />
          </u:specialDates>

        </u:Calendar>           
    </l:content>
</l:VerticalLayout>

Controller

setCalendarModel: function(){
    var selectedDates = {
        germalSplDts: [{
            "date": {
                "day": 1,
                "month": 1,
                "year": 2022,
                "dayOfWeek": 6
            },
            "name": [{
                "lang": "de",
                "text": "Neujahrstag"
            }, {
                "lang": "en",
                "text": "New Year's Day"
            }],
            "holidayType": "public_holiday"
        }, {
            "date": {
                "day": 15,
                "month": 4,
                "year": 2022,
                "dayOfWeek": 5
            },
            "name": [{
                "lang": "de",
                "text": "Karfreitag"
            }, {
                "lang": "en",
                "text": "Good Friday"
            }],
            "holidayType": "public_holiday"
        }, {
            "date": {
                "day": 18,
                "month": 4,
                "year": 2022,
                "dayOfWeek": 1
            },
            "name": [{
                "lang": "de",
                "text": "Ostermontag"
            }, {
                "lang": "en",
                "text": "Easter Monday"
            }],
            "holidayType": "public_holiday"
        }, {
            "date": {
                "day": 1,
                "month": 5,
                "year": 2022,
                "dayOfWeek": 7
            },
            "name": [{
                "lang": "de",
                "text": "Tag der Arbeit"
            }, {
                "lang": "en",
                "text": "Labour Day"
            }],
            "holidayType": "public_holiday"
        }, {
            "date": {
                "day": 26,
                "month": 5,
                "year": 2022,
                "dayOfWeek": 4
            },
            "name": [{
                "lang": "de",
                "text": "Christi Himmelfahrt"
            }, {
                "lang": "en",
                "text": "Ascension Day"
            }],
            "holidayType": "public_holiday"
        }, {
            "date": {
                "day": 6,
                "month": 6,
                "year": 2022,
                "dayOfWeek": 1
            },
            "name": [{
                "lang": "de",
                "text": "Pfingstmontag"
            }, {
                "lang": "en",
                "text": "Whit Monday"
            }],
            "holidayType": "public_holiday"
        }, {
            "date": {
                "day": 3,
                "month": 10,
                "year": 2022,
                "dayOfWeek": 1
            },
            "name": [{
                "lang": "de",
                "text": "Tag der Deutschen Einheit"
            }, {
                "lang": "en",
                "text": "German Unity Day"
            }],
            "holidayType": "public_holiday"
        }, {
            "date": {
                "day": 25,
                "month": 12,
                "year": 2022,
                "dayOfWeek": 7
            },
            "name": [{
                "lang": "de",
                "text": "Weihnachtstag"
            }, {
                "lang": "en",
                "text": "Christmas Day"
            }],
            "holidayType": "public_holiday"
        }, {
            "date": {
                "day": 26,
                "month": 12,
                "year": 2022,
                "dayOfWeek": 1
            },
            "name": [{
                "lang": "de",
                "text": "Zweiter Weihnachtsfeiertag"
            }, {
                "lang": "en",
                "text": "Boxing Day"
            }],
            "holidayType": "public_holiday"
        }]

    };

    // create a Model and assign it to the View
    var oModel = new sap.ui.model.json.JSONModel();
    oModel.setData(selectedDates);
    this.getView().setModel(oModel);
}

Note: I have hard coded the results which I got it from the below API. Kindly use the below API to get the same results using the ajax call.

For example: https://kayaposoft.com/enrico/json/v2.0/?action=getHolidaysForDateRange&fromDate=01-01-2022&toDate=30-12-2022&country=deu&holidayType=public_holiday

Inizio
  • 2,226
  • 15
  • 18