Skip to content

Commit

Permalink
SAK-42809 Assignments integrateWithAnnouncements should display timez…
Browse files Browse the repository at this point in the history
…one in the anncouncement message (sakaiproject#7592)
  • Loading branch information
austin48 authored and ern committed Nov 26, 2019
1 parent 8d839e5 commit 18dd720
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

import java.io.OutputStream;
import java.time.Instant;
import java.time.format.FormatStyle;
import java.util.Collection;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -741,6 +742,8 @@ public String getDeepLinkWithPermissions(String context, String assignmentId, bo

String getUsersLocalDateTimeString(Instant date);

String getUsersLocalDateTimeString(Instant date, FormatStyle dateStyle, FormatStyle timeStyle);

public List<ContentReviewResult> getContentReviewResults(AssignmentSubmission submission);

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4190,9 +4190,15 @@ private void notificationToStudent(AssignmentSubmission submission) {

@Override
public String getUsersLocalDateTimeString(Instant date) {
if (date == null) return "";
return getUsersLocalDateTimeString(date, FormatStyle.MEDIUM, FormatStyle.SHORT);
}

public String getUsersLocalDateTimeString(Instant date, FormatStyle dateStyle, FormatStyle timeStyle) {
if (date == null) return "";
if (dateStyle == null) { dateStyle = FormatStyle.MEDIUM; }
if (timeStyle == null) { timeStyle = FormatStyle.SHORT; }
ZoneId zone = userTimeService.getLocalTimeZone().toZoneId();
DateTimeFormatter df = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.MEDIUM, FormatStyle.SHORT)
DateTimeFormatter df = DateTimeFormatter.ofLocalizedDateTime(dateStyle, timeStyle)
.withZone(zone)
.withLocale(resourceLoader.getLocale());
return df.format(date);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8156,7 +8156,7 @@ private void integrateWithAnnouncement(SessionState state, String aOldTitle, Ass
header.setSubject(/* subject */rb.getFormattedMessage("assig5", title));
}

String formattedOpenTime = assignmentService.getUsersLocalDateTimeString(openTime);
String formattedOpenTime = assignmentService.getUsersLocalDateTimeString(openTime, FormatStyle.MEDIUM, FormatStyle.LONG);
if (updatedOpenDate) {
// revised assignment open date
message.setBody(/* body */ "<p>" + rb.getFormattedMessage("newope", formattedText.convertPlaintextToFormattedText(title), formattedOpenTime) + "</p>");
Expand Down

0 comments on commit 18dd720

Please sign in to comment.