Implementing website’s header opening hours with the Working Days API

 

In this tutorial, we will see how a webmaster could easily manage an opening hour header on his website using the working days API and the working day's websites time schedule management 



Use Case

A cultural establishment located in New York City is opened to public from Tuesday to Sunday from 11:00 to 18:00.

It remains open on every federal public holidays except on Thanksgiving Day and Christmas Day.

Every first Saturday of the month, it stays open until 23:00 for special night events.

Each year, there is an annual closure for maintenance, usually in august but the dates may change every year and needs to be configured easily.

The establishment has a website, it would be nice if it could give the opening hours of the day on the home page.

All of that can be implemented within a few minutes thanks to the working days API.


Tutorial

 First let's go the workingdays.us , log in using any email (you will need to be logged in to able to create profiles), and select the applicable public holidays:


Next, from the setup screen select the weekend days and define the week time schedule:


From the setup screen, open the "Custom dates" panel -> "Periodic dates" sub panel and create the custom following rule:


From any calendar view, click and drag the mouse to define the annual closures periods (you can choose a color, to help you organize your own categories: for example, orange for inventory closure, yellow for exceptional closures due to the pandemic, and so on…):


Now our calendar is fully configured, let's copy the profile's ID (a profile ID is a 6 characters unique secret that identifies a calendar and all its associated parameters):


 The webmaster of the establishment just needs to run this request every morning (typically through a cron) to display the opening hours of the establishment:

/get_info_day?country_code=US&date=2022-07-02&profile_id=56CBB0

and will get this kind of JSON response:

{

"result":{

"working_day":"1",

"work_hours":"12",

"wages":"240",

"morning_start":"11:00",

"morning_end":"14:00",

"afternoon_start":"14:00",

"afternoon_end":"23:00",

"public_holiday":"0",

"public_holiday_description":"",

"weekend_day":"0",

"custom_date":"1",

"custom_date_description":"special night",

"custom_date_color":"periodic",

                "type":8

}

}


Comments

Popular Posts