Workday Calendar

Overview

Workday Calendar contains a list of dates which are exceptions to the regular workday calendar such as observed holidays and weekend working days.

The list can be associated with a country, a region, a specific organization, such as a stock exchange or a school district.

Each calendar is assigned a unique key which can be accessed in the rule engine or via SQL queries to check if the given day is a working day based on the actual observed calendar.

Usage

Rule Engine

now.is_workday()
!tomorrow.is_workday('kor')

Warning

The function raises an error if no dates are found in the specified calendar for the given year. Update the calendar by adding dates to resolve this problem.

SQL Queries

SELECT date_format(time, 'yyyy-MM-dd'), SUM(value)
  FROM visitor_count
WHERE time >= current_year
  AND date_format(time, 'u') < 6 AND NOT IS_WORKDAY(time)

Built-in Calendars

By default, the database contains pre-defined workday calendars for several countries for years 2018-2020.

Calendars can be modified and maintained by appending dates for prior and future years without restarting the database.

Once installed, the calendars are not updated as part of the database update process. To install new calendars, download them from the table below and import the files into your ATSD instance.

Country Calendar Key Download
Australia aus download
Austria aut download
Brazil bra download
Canada can download
China chn download
Germany deu download
France fra download
Great Britain gbr download
Israel isr download
Japan jpn download
Korea kor download
Russia rus download
Singapore sgp download
USA usa download

Custom Calendars

Schema

Define new calendars in JSON format according to Workday Calendar Schema.

{
  "country": "USA",
  "data": [
    { "date": "2019-01-01", "type": "Holiday" },
    { "date": "2019-01-05", "type": "Workday" },
    ...
  ]
}

Country name is specified as the ISO-3166 alpha-3 country code.

Each exception in the list is classified as either a Holiday or Workday:

  • A Holiday is assigned when the regular working day becomes a non-working day based on observance.
  • A regular weekend day which is changed to a working day due to calendar optimizations is classified as a Workday.

Once loaded into the database, a calendar is accessible via the calendar key which is based on the file name excluding .json extension.

The calendar file can include days for any number of years.

Importing Calendar

Open the Data Entry > Workday Calendars page. Attach one or multiple JSON files and click Import.

Uploaded files are copied to /opt/atsd/atsd/conf/calendars and changes apply instantly. Database restart is not required.

Example

The example below illustrates a custom workday calendar for the New York Stock Exchange.

The calendar is named nyse.json and can be accessed under the nyse key, for example now.is_workday('nyse').

{
  "country": "USA",
  "data": [
    { "date": "2018-01-01", "type": "Holiday", "description": "New Years Day" },
    { "date": "2018-01-15", "type": "Holiday", "description": "Martin Luther King, Jr. Day" },
    { "date": "2018-02-19", "type": "Holiday", "description": "Washington's Birthday" },
    { "date": "2018-03-30", "type": "Holiday", "description": "Good Friday" },
    { "date": "2018-05-28", "type": "Holiday", "description": "Memorial Day" },
    { "date": "2018-07-04", "type": "Holiday", "description": "Independence Day" },
    { "date": "2018-09-03", "type": "Holiday", "description": "Labor Day" },
    { "date": "2018-11-22", "type": "Holiday", "description": "Thanksgiving Day" },
    { "date": "2018-12-25", "type": "Holiday", "description": "Christmas" }
  ]
}