Skip to content

Calendar

Performs calendar-aware date arithmetic in workflow scripts.

Remarks

In instance scripts, $Calendar and $Calendar2 follow $Instance.Calendar and refresh their cached schedule when that selection changes. A null selection uses Default; if Default is not configured, an empty schedule is used. Other server contexts use Default. Explicit calendars created by Get(), Parse(), or presets keep their own rules. Named calendars raise an error if the schedule is not configured. Date inputs must be convertible to DateTimeOffset; invalid values and invalid duration or time-zone strings raise script errors.

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 total number of hours in the specified date.
  • 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 with 7/24 hours (24 hours, 7 days a week).
  • Calendar.GetWeekendCalendar: Gets the weekend calendar with 5/24 hours (24 hours, 5 days a week).
  • Calendar.Parse: Parses a calendar rule from an XML string or Xml object and returns a Calendar object.

Async Calendar Queries