Skip to content
Reference > AmiScript API > Classes

Date

Definition

Date var = .... ;

Extends

Extended By

None

Description

A representation of year month and day as a Date.

Method Summary

Owner Name Return Type Description
Date constructor(value) Object Initialize a Date object.
Date constructor(value) Object Initialize a Date object.
Date constructor() Object Creates a Date object using the current time and local timezone.
Object getClassName() String Returns the string name of this object's class type.
Date getDay() Integer Returns the day of month value
Date getDayOfWeek() Integer Returns the day of week value
Date getDays() Integer Returns the number of days since epoch day of this date object.
Date getFirstDayOfMonth() Date Returns the first day of the date object's month as a date object
Date getFirstDayOfWeek() Date Returns the first day of the date object's week as a date object
Date getFirstDayOfYear() Date Returns the first day of the date object's year as a date object
Date getLastDayOfMonth() Date Returns the last day of the date object's month as a date object
Date getLastDayOfWeek() Date Returns the last day of the date object's week as a date object
Date getLastDayOfYear() Date Returns the last day of the date object's year as a date object
Date getMonth() Integer Returns the month of year value
Date getYear() Integer Returns the year value
Date isWeekday() Boolean Returns true if the current date is a weekday
Date isWeekend() Boolean Returns true if the current date is a weekend
Date shiftCalendarDay(offsetDays) Date Returns the date the given number of calendar days from this date (positive = later, negative = earlier).
Date shiftCalendarMonth(offsetMonths) Date Returns the date the given number of calendar months from this date (positive = later, negative = earlier).
Date shiftCalendarWeek(offsetWeeks) Date Returns the date the given number of calendar weeks from this date (positive = later, negative = earlier).
Date shiftCalendarYear(offsetYears) Date Returns the date the given number of calendar years from this date (positive = later, negative = earlier).
Object toJson() String Returns a string of a json representation of this object.
Date toLegibleDayOfWeek() String Returns the day of week formatted string of the date object
Date toLegibleMonth() String Returns the month formatted string of the date object
Date toLegibleString() String Returns the yyyyMMdd formatted string of the date object

Method Definitions


constructor(value)

Date date = new Date(String value)

Description

Initialize a Date object.

Parameter Definition

Name Type Description
value String  a yyyyMMdd string value

Example 1

1
2
3
Date d = "20251225";

// d = 2025-12-25

constructor(value)

Date date = new Date(Integer value)

Description

Initialize a Date object.

Parameter Definition

Name Type Description
value Integer  number of days since epoch day

Example 1

1
2
3
Date d = 20447;

// d = 2025-12-25

constructor()

Date date = new Date()

Description

Creates a Date object using the current time and local timezone.


getClassName()

String Object::getClassName()

Description

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


getDay()

Integer Date::getDay()

Description

Returns the day of month value


getDayOfWeek()

Integer Date::getDayOfWeek()

Description

Returns the day of week value


getDays()

Integer Date::getDays()

Description

Returns the number of days since epoch day of this date object.

Example 1

1
2
3
Date d = 20447;

// d.getDays() = 20447

getFirstDayOfMonth()

Date Date::getFirstDayOfMonth()

Description

Returns the first day of the date object's month as a date object


getFirstDayOfWeek()

Date Date::getFirstDayOfWeek()

Description

Returns the first day of the date object's week as a date object


getFirstDayOfYear()

Date Date::getFirstDayOfYear()

Description

Returns the first day of the date object's year as a date object


getLastDayOfMonth()

Date Date::getLastDayOfMonth()

Description

Returns the last day of the date object's month as a date object


getLastDayOfWeek()

Date Date::getLastDayOfWeek()

Description

Returns the last day of the date object's week as a date object


getLastDayOfYear()

Date Date::getLastDayOfYear()

Description

Returns the last day of the date object's year as a date object


getMonth()

Integer Date::getMonth()

Description

Returns the month of year value


getYear()

Integer Date::getYear()

Description

Returns the year value


isWeekday()

Boolean Date::isWeekday()

Description

Returns true if the current date is a weekday


isWeekend()

Boolean Date::isWeekend()

Description

Returns true if the current date is a weekend


shiftCalendarDay(offsetDays)

Date Date::shiftCalendarDay(Number offsetDays)

Description

Returns the date the given number of calendar days from this date (positive = later, negative = earlier).

Parameter Definition

Name Type Description
offsetDays Number  Number of days to offset from this date. A positive number indicates days after this date; a negative number indicates days before it.

shiftCalendarMonth(offsetMonths)

Date Date::shiftCalendarMonth(Number offsetMonths)

Description

Returns the date the given number of calendar months from this date (positive = later, negative = earlier).

Parameter Definition

Name Type Description
offsetMonths Number  Number of months to offset from this date. A positive number indicates months after this date; a negative number indicates months before it.

shiftCalendarWeek(offsetWeeks)

Date Date::shiftCalendarWeek(Number offsetWeeks)

Description

Returns the date the given number of calendar weeks from this date (positive = later, negative = earlier).

Parameter Definition

Name Type Description
offsetWeeks Number  Number of weeks to offset from this date. A positive number indicates weeks after this date; a negative number indicates weeks before it.

shiftCalendarYear(offsetYears)

Date Date::shiftCalendarYear(Number offsetYears)

Description

Returns the date the given number of calendar years from this date (positive = later, negative = earlier).

Parameter Definition

Name Type Description
offsetYears Number  Number of years to offset from this date. A positive number indicates years after this date; a negative number indicates years before it.

toJson()

String Object::toJson()

Description

Returns a string of a json representation of this object.


toLegibleDayOfWeek()

String Date::toLegibleDayOfWeek()

Description

Returns the day of week formatted string of the date object

Example 1

1
2
3
Date d = 20447;

// d.toLegibleDayOfWeek() = Thursday

toLegibleMonth()

String Date::toLegibleMonth()

Description

Returns the month formatted string of the date object

Example 1

1
2
3
Date d = 20447;

// d.toLegibleMonth() = December

toLegibleString()

String Date::toLegibleString()

Description

Returns the yyyyMMdd formatted string of the date object

Example 1

1
2
3
Date d = 20447;

// d.toLegibleString() = 2025-12-25