ScopeToTimeZone method

DateTime ScopeToTimeZone(
  1. ExchangeServiceBase service,
  2. DateTime dateTime,
  3. PropertyBag propertyBag,
  4. bool isUpdateOperation,
)
Scopes the date time property to the appropriate time zone, if necessary. The service emitting the request. The date time. The property bag. Indicates whether the scoping is to be performed in the context of an update operation.

Implementation

DateTime ScopeToTimeZone(
  ExchangeServiceBase service,
  DateTime dateTime,
  PropertyBag propertyBag,
  bool isUpdateOperation,
) {
  try {
    // Plain local DateTimes are C#'s Unspecified kind: they are scoped to the
    // service's time zone (the platform's local time zone when none is set).
    return service.ConvertDateTimeToUniversalDateTime(dateTime);
  } on TimeZoneConversionException catch (e, stacktrace) {
    throw PropertyException(
      "InvalidDateTime($dateTime)",
      Name,
      e,
      stacktrace,
    );
  }
}