Skip to content

$Calendar

Provides the default calendar instance with domain-specific calendar rules.

1
const $Calendar: Calendar;

Remarks

$Calendar is used to obtain the current date and time, perform date and time arithmetic (addition and subtraction), and manage time zone conversions.

$Calendar can be utilized in both client-side and server-side scripts. In server-side scripts, both synchronous and asynchronous methods are supported. However, client-side scripts are restricted to asynchronous methods due to their inherent asynchronous nature.

$Calendar defaults to using the domain calendar rules. For specific calendar implementations, refer to the Calendar.StandardCalendar or Calendar.WeekendCalendar objects.

Examples

Add days in a server script

1
var tomorrow = $Calendar.AddDays(DateTimeOffset.now, 1);

Add days in a form script

1
2
3
$Calendar.AddDaysAsync(DateTimeOffset.now, 2).then(function (date) {
    $Xml.SetValue('FollowUpDate', date);
});

Capabilities

Presets

Calendar Queries

  • $Calendar.Today: Returns the current date and time in UTC time.
  • $Calendar.GetDateTime: Returns the next valid date and time, according to calendar rules, after adding the given duration to the specified date.
  • $Calendar.GetHoursInDay: Returns the number of hours the calendar includes on the specified date, such as the working hours of the day.
  • $Calendar.GetToday: Returns the current date and time in the specified time zone.

Date Arithmetic

  • $Calendar.Add: Adds a specified number of hours to a DateTimeOffset value and returns the result.
  • $Calendar.AddDays: Adds a specified number of days to a DateTimeOffset value and returns the next valid date and time according to the calendar rules.
  • $Calendar.AddMonth: Adds calendar months and adjusts the result to the next time included by this calendar.
  • $Calendar.AddMonths: Adds a specified number of months to a DateTimeOffset value and returns the result.
  • $Calendar.AddTimeSpan: Returns a new DateTimeOffset by adding a specified duration, considering calendar rules.
  • $Calendar.AddYear: Adds calendar years and adjusts the result to the next time included by this calendar.
  • $Calendar.AddYears: Adds a specified number of years to a DateTimeOffset value and returns the result.
  • $Calendar.Subtract: Subtracts one date-time value from another and returns the difference in hours.

Async Date Arithmetic

Time Zones

Async Time Zones

Creation and Presets

  • $Calendar.Get: Returns a new calendar using the named business schedule from the instance's originating domain, or the current domain outside instance scripts.
  • $Calendar.GetStandardCalendar: Gets the standard calendar, which includes every hour of every day (24 hours, 7 days a week).
  • $Calendar.GetWeekendCalendar: Gets a calendar that excludes weekends: every hour from Monday to Friday is included, and Saturday and Sunday are excluded.
  • $Calendar.Parse: Parses a calendar rule from an XML string or Xml object and returns a Calendar object.

Async Calendar Queries

See Also