Method ToExpirationTime
ToExpirationTime(Nullable<DateTime>)
Converts TTL to absolute expiration time.
Declaration
public DateTime ToExpirationTime(Nullable<DateTime> referenceTime = null)
Parameters
Type | Name | Description |
---|---|---|
Nullable<DateTime> | referenceTime | (Optional) Reference time. Defaults to UtcNow. |
Returns
Type | Description |
---|---|
DateTime | Expiration time, in UTC. |
Remarks
This method converts TTL to absolute expiration time given the reference time from which to measure the expiration. If the reference time is not provided, it defaults to current time. The semantics follows the rounding behavior described so that the returned value will be rounded up to the nearest hour or day boundary.
The value returned is always in UTC (its
System.DateTime.Kind is Utc). If
referenceTime
is not in UTC it will be converted
to UTC via ToUniversalTime() before
computing the expiration time (this also means that both
Unspecified and
Local will be treated as local time
and the conversion would be performed).
Exceptions
Type | Condition |
---|---|
NotSupportedException | If this instance is DoNotExpire. |
ArgumentOutOfRangeException | If the resulting expiration time is greater than MaxValue. |