Skip to content

Commit

Permalink
fix(mail): fix end date of all-day event in mail notifications
Browse files Browse the repository at this point in the history
Fixes #4145
  • Loading branch information
cgx committed Jul 9, 2021
1 parent f8f4de6 commit 694ffa7
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 13 deletions.
30 changes: 24 additions & 6 deletions SoObjects/Appointments/SOGoAptMailNotification.m
Expand Up @@ -106,7 +106,8 @@ - (NSCalendarDate *) oldStartDate
if (!oldStartDate)
{
ASSIGN (oldStartDate, [[self previousApt] startDate]);
[oldStartDate setTimeZone: viewTZ];
if (![(iCalEvent*)[self previousApt] isAllDay])
[oldStartDate setTimeZone: viewTZ];
}
return oldStartDate;
}
Expand All @@ -116,33 +117,50 @@ - (NSCalendarDate *) newStartDate
if (!newStartDate)
{
ASSIGN (newStartDate, [[self apt] startDate]);
[newStartDate setTimeZone: viewTZ];
if (![(iCalEvent*)[self apt] isAllDay])
[newStartDate setTimeZone: viewTZ];
}
return newStartDate;
}

- (NSCalendarDate *) oldEndDate
{
NSCalendarDate *endDate;

if (!oldEndDate)
{
if ([[self previousApt] isKindOfClass: [iCalEvent class]])
ASSIGN (oldEndDate, [(iCalEvent*)[self previousApt] endDate]);
{
endDate = [(iCalEvent*)[self previousApt] endDate];
if ([(iCalEvent*)[self previousApt] isAllDay])
endDate = [endDate dateByAddingYears:0 months:0 days:0 hours:0 minutes:0 seconds:-1];
ASSIGN (oldEndDate, endDate);
}
else
ASSIGN (oldEndDate, [(iCalToDo*)[self previousApt] due]);
[oldEndDate setTimeZone: viewTZ];
if (![(iCalEvent*)[self previousApt] isAllDay])
[oldEndDate setTimeZone: viewTZ];
}
return oldEndDate;
}

- (NSCalendarDate *) newEndDate
{
NSCalendarDate *endDate;

if (!newEndDate)
{
if ([[self apt] isKindOfClass: [iCalEvent class]])
ASSIGN (newEndDate, [(iCalEvent*)[self apt] endDate]);
{
endDate = [(iCalEvent*)[self apt] endDate];
if ([(iCalEvent*)[self apt] isAllDay])
endDate = [endDate dateByAddingYears:0 months:0 days:0 hours:0 minutes:0 seconds:-1];
ASSIGN (newEndDate, endDate);
}
else
ASSIGN (newEndDate, [(iCalToDo*)[self apt] due]);
[newEndDate setTimeZone: viewTZ];
if (![(iCalEvent*)[self apt] isAllDay])
[newEndDate setTimeZone: viewTZ];
}
return newEndDate;
}
Expand Down
10 changes: 6 additions & 4 deletions UI/MailPartViewers/UIxMailPartICalViewer.m
Expand Up @@ -143,7 +143,8 @@ - (NSCalendarDate *) startCalendarDate

date = [[self inEvent] startDate];
ud = [[context activeUser] userDefaults];
[date setTimeZone: [ud timeZone]];
if (![[self inEvent] isAllDay])
[date setTimeZone: [ud timeZone]];

return date;
}
Expand Down Expand Up @@ -186,12 +187,12 @@ - (NSString *) formattedDateTime
if ([self isEndDateOnSameDay] &&
![[self inEvent] isAllDay])
{
[s appendFormat: @" %@", [self labelForKey: @"to"]];
[s appendFormat: @" %@", [self labelForKey: @"to_time"]];
[s appendFormat: @" %@", [self endTime]];
}
else if (![self isEndDateOnSameDay])
{
[s appendFormat: @" %@", [self labelForKey: @"to"]];
[s appendFormat: @" %@", [self labelForKey: @"to_date"]];
[s appendFormat: @" %@", [self endDate]];

if (![[self inEvent] isAllDay])
Expand All @@ -218,7 +219,8 @@ - (NSCalendarDate *) endCalendarDate

date = [[self inEvent] endDate];
ud = [[context activeUser] userDefaults];
[date setTimeZone: [ud timeZone]];
if (![[self inEvent] isAllDay])
[date setTimeZone: [ud timeZone]];

return date;
}
Expand Down
6 changes: 6 additions & 0 deletions UI/MailerUI/English.lproj/Localizable.strings
Expand Up @@ -251,6 +251,12 @@
/* Number of selected messages in list */
"selected" = "selected";

/* Date formatting from one time to another time */
"to_time" = "to";

/* Date formatting from one day to another day */
"to_date" = "to";

/* Encrypted message notification */
"This message is encrypted" = "This message is encrypted";

Expand Down
6 changes: 6 additions & 0 deletions UI/MailerUI/French.lproj/Localizable.strings
Expand Up @@ -251,6 +251,12 @@
/* Number of selected messages in list */
"selected" = "sélectionné(s)";

/* Date formatting from one time to another time */
"to_time" = "à";

/* Date formatting from one day to another day */
"to_date" = "au";

/* Encrypted message notification */
"This message is encrypted" = "Ce message est crypté";

Expand Down
17 changes: 14 additions & 3 deletions UI/Templates/Appointments/SOGoAptMailDeletion.wox
Expand Up @@ -19,11 +19,21 @@ th, td { font-family: Lucida Grande, Bitstream VeraSans, Tahoma, sans-serif; fon
padding-bottom: 9px; border-bottom: 1px solid #ccc;" class="ng-hide"><var:string
value="getSubject" const:escapeHTML="NO"/> <small style="font-size: 12px; color: #999;"><var:string
value="organizerName" const:escapeHTML="NO"/><var:string value="sentByText" const:escapeHTML="NO"/></small></h1></td>
</tr>
<tr>
</tr> <var:if condition="location.length"
><tr>
<th align="right" style="font-weight: bold;"><var:string label:value="location_label" const:escapeHTML="NO"/></th>
<td><var:string value="location" const:escapeHTML="NO"/></td>
</tr></var:if>

<var:if condition="apt.isAllDay">
<tr>
<th align="right" style="font-weight: bold;"><var:string label:value="time_label" const:escapeHTML="NO"/></th>
<td><var:string value="formattedAptStartDate"
const:escapeHTML="NO"/><var:if condition="isEndDateOnSameDay" const:negate="YES"> <var:string label:value="to_label" const:escapeHTML="NO"/> <var:string value="formattedAptEndDate" const:escapeHTML="NO"/>
</var:if></td>
</tr>
</var:if>
<var:if condition="apt.isAllDay" const:negate="YES">
<tr>
<th align="right" style="font-weight: bold;"><var:string label:value="startDate_label" const:escapeHTML="NO"/></th>
<td><var:string value="formattedAptStartDate" const:escapeHTML="NO"
Expand All @@ -34,8 +44,9 @@ th, td { font-family: Lucida Grande, Bitstream VeraSans, Tahoma, sans-serif; fon
<th align="right" style="font-weight: bold;"><var:string label:value="endDate_label" const:escapeHTML="NO"/></th>
<td><var:string value="formattedAptEndDate" const:escapeHTML="NO"
/><var:if condition="formattedAptEndTime.length"> - <var:string value="formattedAptEndTime" const:escapeHTML="NO"/> <var:string value="viewTZ" const:escapeHTML="NO"/>
</var:if></td>
</var:if></td>
</tr>
</var:if>
<var:if condition="apt.comment.length"
><tr>
<th align="right" style="font-weight: bold;"><var:string label:value="comment_label" const:escapeHTML="NO"/></th>
Expand Down

0 comments on commit 694ffa7

Please sign in to comment.