@@ -1813,13 +1813,16 @@ void EWSContext::toContent(const std::string& dir, tCalendarItem& item, sShape&
18131813 shape.write (TAGGED_PROPVAL{PR_MESSAGE_CLASS, deconst (" IPM.Appointment" )});
18141814 int64_t startOffset = 0 , endOffset = 0 ;
18151815 time_t startTime = 0 , endTime = 0 ;
1816+ bool calcStartOffset, calcEndOffset = false ;
18161817 if (item.Start ) {
18171818 startTime = clock::to_time_t (item.Start .value ().time );
18181819 startOffset = std::chrono::duration_cast<std::chrono::minutes>(item.Start .value ().offset ).count ();
1820+ calcStartOffset = item.Start .value ().needCalcOffset ();
18191821 }
18201822 if (item.End ) {
18211823 endTime = clock::to_time_t (item.End .value ().time );
18221824 endOffset = std::chrono::duration_cast<std::chrono::minutes>(item.Start .value ().offset ).count ();
1825+ calcEndOffset = item.Start .value ().needCalcOffset ();
18231826 }
18241827 // TODO handle no start and/or end times
18251828
@@ -2035,17 +2038,20 @@ void EWSContext::toContent(const std::string& dir, tCalendarItem& item, sShape&
20352038 shape.write (NtAppointmentTimeZoneDefinitionEndDisplay,
20362039 TAGGED_PROPVAL{PT_BINARY, temp_bin});
20372040
2038- // If the offsets of start or end times are not set, probably
2039- // the client didn't send the offset information in date tags.
2040- // Try to get the offset from the timezone definition.
2041- if (startOffset == 0 || endOffset == 0 )
2041+ // If the offsets of start or end times are 0 and
2042+ // the client didn't send the offset information in date tags,
2043+ // try to get the offset from the timezone definition.
2044+ if (( startOffset == 0 && calcStartOffset) || ( endOffset == 0 && calcEndOffset) )
20422045 {
20432046 EXT_PULL ext_pull;
20442047 TIMEZONEDEFINITION tzdef;
20452048 ext_pull.init (buf->data (), buf->size (), alloc, EXT_FLAG_UTF16);
20462049 if (ext_pull.g_tzdef (&tzdef) != EXT_ERR_SUCCESS)
20472050 throw EWS::DispatchError (E3294 );
2048- startOffset = endOffset = offset_from_tz (&tzdef, startTime);
2051+ if (calcStartOffset)
2052+ startOffset = offset_from_tz (&tzdef, startTime);
2053+ if (calcEndOffset)
2054+ endOffset = offset_from_tz (&tzdef, endTime);
20492055 }
20502056 item.Start .value ().offset = std::chrono::minutes (startOffset);
20512057 item.End .value ().offset = std::chrono::minutes (endOffset);
0 commit comments