Skip to content
Reference > AmiScript API > Classes

Calendar

Definition

Calendar var = .... ;

Extends

Extended By

None

Description

A custom business/holiday calendar.

Method Summary

Owner Name Return Type Description
Calendar constructor(holidaySet, extraWorkdaySet, standardWorkDays) Object Initialize a Calendar object given custom business/holiday schedule.
Calendar constructor(holidaySet, extraWorkdaySet) Object Initialize a Calendar object given custom business/holiday schedule.
Calendar constructor(holidaySet) Object Initialize a Calendar object given custom holiday schedule.
Calendar getBusinessDayOffsetBy(targetDate, offsetDays) Date Returns the date obtained by adding or subtracting the given number of business days to the target date object in this calendar context.
Object getClassName() String Returns the string name of this object's class type.
Calendar getFirstBusinessDayOfMonth(targetDate) Date Returns the first business day of the date object's month as a date object in this calendar context.
Calendar getFirstBusinessDayOfWeek(targetDate) Date Returns the first business day of the date object's week as a date object in this calendar context.
Calendar getFirstBusinessDayOfYear(targetDate) Date Returns the first business day of the date object's year as a date object in this calendar context.
Calendar getLastBusinessDayOfMonth(targetDate) Date Returns the last business day of the date object's month as a date object in this calendar context.
Calendar getLastBusinessDayOfWeek(targetDate) Date Returns the last business day of the date object's week as a date object in this calendar context.
Calendar getLastBusinessDayOfYear(targetDate) Date Returns the last business day of the date object's year as a date object in this calendar context.
Calendar isBusinessDay(targetDate) Boolean Returns true if the date supplied is a business day and false otherwise in this calendar context.
Calendar isHoliday(targetDate) Boolean Returns true if the date supplied is a holiday and false otherwise in this calendar context.
Calendar isWeekday(targetDate) Boolean Returns true if the date's day-of-week is part of this calendar's standard work week, and false otherwise. Holidays and extra workdays are not considered.
Calendar isWeekend(targetDate) Boolean Returns true if the date's day-of-week is outside this calendar's standard work week (e.g. Sat/Sun for a Mon-Fri calendar), and false otherwise. Holidays and extra workdays are not considered.
Object toJson() String Returns a string of a json representation of this object.

Method Definitions


constructor(holidaySet,extraWorkdaySet,standardWorkDays)

Calendar calendar = new Calendar(Collection holidaySet, Collection extraWorkdaySet, Collection standardWorkDays)

Description

Initialize a Calendar object given custom business/holiday schedule.

Parameter Definition

Name Type Description
holidaySet Collection  The set of holiday dates.
extraWorkdaySet Collection  A set of weekend days that are readjusted into work days
standardWorkDays Collection  A set of days of a week (represented by integers where Monday = 1, Tuesday = 2, ... Sunday = 7) that are considered business or working days.

Example 1

Calendar c = new Calendar([new Date("20251105"), new Date("20251106")], [new Date("20251107")], [7,1,2,3,4]);
// c = November 2025
Mon Tue Wed Thu Fri Sat Sun
                    * 1   2 
  3   4 * 5 * 6   7 * 8   9 
 10  11  12  13 *14 *15  16 
 17  18  19  20 *21 *22  23 
 24  25  26  27 *28 *29  30 


December 2025
Mon Tue Wed Thu Fri Sat Sun
  1   2   3   4 * 5 * 6   7 
  8   9  10  11 *12 *13  14 
 15  16  17  18 *19 *20  21 
 22  23  24  25 *26 *27  28 
 29  30  31 

constructor(holidaySet,extraWorkdaySet)

Calendar calendar = new Calendar(Collection holidaySet, Collection extraWorkdaySet)

Description

Initialize a Calendar object given custom business/holiday schedule.

Parameter Definition

Name Type Description
holidaySet Collection  The set of holiday dates.
extraWorkdaySet Collection  A set of weekend days that are readjusted into work days

Example 1

Calendar c = new Calendar([new Date("20251109"), new Date("20251110")], [new Date("20251107")]);

// c = November 2025
Mon Tue Wed Thu Fri Sat Sun
                    * 1 * 2 
  3   4   5   6   7 * 8 * 9 
*10  11  12  13  14 *15 *16 
 17  18  19  20  21 *22 *23 
 24  25  26  27  28 *29 *30 


December 2025
Mon Tue Wed Thu Fri Sat Sun
  1   2   3   4   5 * 6 * 7 
  8   9  10  11  12 *13 *14 
 15  16  17  18  19 *20 *21 
 22  23  24  25  26 *27 *28 
 29  30  31 

constructor(holidaySet)

Calendar calendar = new Calendar(Collection holidaySet)

Description

Initialize a Calendar object given custom holiday schedule.

Parameter Definition

Name Type Description
holidaySet Collection  The set of holiday dates.

Example 1

Calendar c = new Calendar(new Set(new Date("20251107")));

// c = November 2025
Mon Tue Wed Thu Fri Sat Sun
                    * 1 * 2 
  3   4   5   6 * 7 * 8 * 9 
 10  11  12  13  14 *15 *16 
 17  18  19  20  21 *22 *23 
 24  25  26  27  28 *29 *30 


December 2025
Mon Tue Wed Thu Fri Sat Sun
  1   2   3   4   5 * 6 * 7 
  8   9  10  11  12 *13 *14 
 15  16  17  18  19 *20 *21 
 22  23  24  25  26 *27 *28 
 29  30  31 

getBusinessDayOffsetBy(targetDate,offsetDays)

Date Calendar::getBusinessDayOffsetBy(Date targetDate, Integer offsetDays)

Description

Returns the date obtained by adding or subtracting the given number of business days to the target date object in this calendar context.

Parameter Definition

Name Type Description
targetDate Date  Target Date
offsetDays Integer  Number of business days to offset from the target date.
A positive number moves forward in time; a negative number moves backward in time.

getClassName()

String Object::getClassName()

Description

Returns the string name of this object's class type.


getFirstBusinessDayOfMonth(targetDate)

Date Calendar::getFirstBusinessDayOfMonth(Date targetDate)

Description

Returns the first business day of the date object's month as a date object in this calendar context.

Parameter Definition

Name Type Description
targetDate Date  Target Date

getFirstBusinessDayOfWeek(targetDate)

Date Calendar::getFirstBusinessDayOfWeek(Date targetDate)

Description

Returns the first business day of the date object's week as a date object in this calendar context.

Parameter Definition

Name Type Description
targetDate Date  Target Date

getFirstBusinessDayOfYear(targetDate)

Date Calendar::getFirstBusinessDayOfYear(Date targetDate)

Description

Returns the first business day of the date object's year as a date object in this calendar context.

Parameter Definition

Name Type Description
targetDate Date  Target Date

getLastBusinessDayOfMonth(targetDate)

Date Calendar::getLastBusinessDayOfMonth(Date targetDate)

Description

Returns the last business day of the date object's month as a date object in this calendar context.

Parameter Definition

Name Type Description
targetDate Date  Target Date

getLastBusinessDayOfWeek(targetDate)

Date Calendar::getLastBusinessDayOfWeek(Date targetDate)

Description

Returns the last business day of the date object's week as a date object in this calendar context.

Parameter Definition

Name Type Description
targetDate Date  Target Date

getLastBusinessDayOfYear(targetDate)

Date Calendar::getLastBusinessDayOfYear(Date targetDate)

Description

Returns the last business day of the date object's year as a date object in this calendar context.

Parameter Definition

Name Type Description
targetDate Date  Target Date

isBusinessDay(targetDate)

Boolean Calendar::isBusinessDay(Date targetDate)

Description

Returns true if the date supplied is a business day and false otherwise in this calendar context.

Parameter Definition

Name Type Description
targetDate Date  Target Date

isHoliday(targetDate)

Boolean Calendar::isHoliday(Date targetDate)

Description

Returns true if the date supplied is a holiday and false otherwise in this calendar context.

Parameter Definition

Name Type Description
targetDate Date  Target Date

isWeekday(targetDate)

Boolean Calendar::isWeekday(Date targetDate)

Description

Returns true if the date's day-of-week is part of this calendar's standard work week, and false otherwise. Holidays and extra workdays are not considered.

Parameter Definition

Name Type Description
targetDate Date  Target Date

isWeekend(targetDate)

Boolean Calendar::isWeekend(Date targetDate)

Description

Returns true if the date's day-of-week is outside this calendar's standard work week (e.g. Sat/Sun for a Mon-Fri calendar), and false otherwise. Holidays and extra workdays are not considered.

Parameter Definition

Name Type Description
targetDate Date  Target Date

toJson()

String Object::toJson()

Description

Returns a string of a json representation of this object.