Skip to content

GetDateTime

Returns the next valid date and time, according to calendar rules, after adding the given duration to the specified date.

1
myCalendar.GetDateTime(duration: string, offset: ( Date | DateTimeOffset )):DateTimeOffset

Parameters

string duration
    The duration to add, in either "d.hh:mm:ss" or ISO-8601 duration format.

( Date | DateTimeOffset ) offset
    The base date and time. Optional; if not specified, the current date and time is used.

Returns

A new DateTimeOffset value representing the next valid date and time, considering calendar rules.

Remarks

This method adds the duration to the given offset (or the current date and time, if no offset is specified) and then finds the next business date and time according to the calendar rules. The resulting value may not be exactly the duration added. If you only need to add the duration in business hours, please use the Calendar.AddTimeSpan method instead.

Warning

This method adds the duration using the standard calendar and returns the next business date and time.

For 09:00-18:00 business hours, adding 2 hours to 17:00 results in the next day at 09:00, not 10:00:

1
2
var nextDate = $Calendar.GetDateTime('PT2H', DateTimeOffset.parse('2023-02-08T17:00'));
// nextDate will be set to '2020-02-09T09:00'

See Also