Calendar¶
Performs calendar-aware date arithmetic in workflow scripts.
Remarks¶
A calendar instance resolves its schedule lazily and caches it for the lifetime of the script. If no schedule is configured, the proxy uses an empty schedule. Date inputs must be convertible to DateTimeOffset; invalid values and invalid duration or time-zone strings raise script errors.
Capabilities¶
Presets¶
- Calendar.StandardCalendar: Gets the standard calendar with 7/24 hours.
- Calendar.WeekendCalendar: Gets the weekend calendar with 5/24 hours.
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
DateTimeOffsetvalue and returns the result. - Calendar.AddDays: Adds a specified number of days to a
DateTimeOffsetvalue 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
DateTimeOffsetvalue and returns the result. - Calendar.AddTimeSpan: Returns a new
DateTimeOffsetby 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
DateTimeOffsetvalue and returns the result. - Calendar.Subtract: Subtracts one date-time value from another and returns the difference in hours.
Async Date Arithmetic¶
- Calendar.AddAsync: Adds a specified number of hours to a
DateTimeOffsetvalue asynchronously. - Calendar.AddDaysAsync: Adds a specified number of days to a
DateTimeOffsetvalue asynchronously. - Calendar.AddMonthsAsync: Adds a specified number of months to a
DateTimeOffsetvalue asynchronously. - Calendar.AddTimeSpanAsync: Adds a specified time span to a
DateTimeOffsetvalue asynchronously. - Calendar.AddYearsAsync: Adds a specified number of years to a
DateTimeOffsetvalue asynchronously. - Calendar.SubtractAsync: Subtracts a
DateTimeOffsetvalue from another and returns the difference in hours asynchronously.
Time Zones¶
- Calendar.ChangeTimeZone: Returns a new
DateTimeOffsetwith the specified time zone offset. - Calendar.GetTimeZone: Returns the time zone information of the specified
DateTimeOffsetvalue.
Async Time Zones¶
- Calendar.ChangeTimeZoneAsync: Returns a new
DateTimeOffsetwith the specified time zone offset asynchronously. - Calendar.GetTimeZoneAsync: Returns the time zone offset of a
DateTimeOffsetvalue asynchronously.
Async Calendar Queries¶
- Calendar.GetDateTimeAsync: Returns the next valid date and time, according to calendar rules, after adding a given duration.
- Calendar.GetHoursInDayAsync: Returns the number of hours included by this calendar on a date.
- Calendar.GetTodayAsync: Returns the current date in the specified time zone asynchronously.
Creation and Presets¶
- 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
Calendarobject.