Skip to content

Commit

Permalink
SAK-48501 Site Manage use a proper date/time format (#13072)
Browse files Browse the repository at this point in the history
  • Loading branch information
maurercw authored Dec 7, 2024
1 parent 0ffe68c commit 815939d
Showing 1 changed file with 18 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
import java.time.ZoneId;
import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeParseException;
import java.util.ArrayList;
import java.util.Arrays;
Expand Down Expand Up @@ -2656,6 +2658,7 @@ else if (state.getAttribute(STATE_CM_REQUESTED_SECTIONS) != null) {
if(daysafter > 0){
context.put("daysafter",daysafter);
}
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss");
if (site != null) {
// editing existing site
context.put("site", site);
Expand Down Expand Up @@ -2689,9 +2692,14 @@ else if (state.getAttribute(STATE_CM_REQUESTED_SECTIONS) != null) {
ZoneId localZoneId = userTimeService.getLocalTimeZone().toZoneId();

termPublishDate = new Date(courseStartTime - (ONE_DAY_IN_MS * daysbefore));
context.put("termStartDate", termPublishDate.toInstant().atZone(localZoneId).toString());
context.put("termEndDate", new Date(courseEndTime).toInstant().atZone(localZoneId).toString());
context.put("termUnpublishDate", new Date(courseEndTime + (ONE_DAY_IN_MS * daysafter)).toInstant().atZone(localZoneId).toString());

ZonedDateTime termStartDate = termPublishDate.toInstant().atZone(localZoneId);
ZonedDateTime termEndDate = new Date(courseEndTime).toInstant().atZone(localZoneId);
ZonedDateTime termUnpublishDate = new Date(courseEndTime + (ONE_DAY_IN_MS * daysafter)).toInstant().atZone(localZoneId);

context.put("termStartDate", termStartDate.format(formatter));
context.put("termEndDate", termEndDate.format(formatter));
context.put("termUnpublishDate", termUnpublishDate.format(formatter));
context.put("readableTermStartDate", userTimeService.dateFormat(termPublishDate, rb.getLocale(), DateFormat.LONG)); //create readable versions of all dates
context.put("readableTermStartDateTime", userTimeService.dateTimeFormat(termPublishDate, rb.getLocale(), DateFormat.SHORT));
context.put("readableTermEndDate", userTimeService.dateFormat(academicSession.getEndDate(), rb.getLocale(), DateFormat.LONG));
Expand Down Expand Up @@ -2818,9 +2826,13 @@ else if (state.getAttribute(STATE_CM_REQUESTED_SECTIONS) != null) {
long courseEndTime = academicSession.getEndDate().getTime();
ZoneId localZoneId = userTimeService.getLocalTimeZone().toZoneId();

context.put("termStartDate", new Date(courseStartTime - (ONE_DAY_IN_MS * daysbefore)).toInstant().atZone(localZoneId).toString());
context.put("termEndDate", new Date(courseEndTime).toInstant().atZone(localZoneId).toString());
context.put("termUnpublishDate", new Date(courseEndTime + (ONE_DAY_IN_MS * daysafter)).toInstant().atZone(localZoneId).toString());
ZonedDateTime termStartDate = new Date(courseStartTime - (ONE_DAY_IN_MS * daysbefore)).toInstant().atZone(localZoneId);
ZonedDateTime termEndDate = new Date(courseEndTime).toInstant().atZone(localZoneId);
ZonedDateTime termUnpublishDate = new Date(courseEndTime + (ONE_DAY_IN_MS * daysafter)).toInstant().atZone(localZoneId);

context.put("termStartDate", termStartDate.format(formatter));
context.put("termEndDate", termEndDate.format(formatter));
context.put("termUnpublishDate", termUnpublishDate.format(formatter));
context.put("readableTermStartDate", userTimeService.dateFormat(new Date(courseStartTime - (ONE_DAY_IN_MS * daysbefore)), rb.getLocale(), DateFormat.LONG)); //create readable versions of all dates
context.put("readableTermEndDate", userTimeService.dateFormat(academicSession.getEndDate(), rb.getLocale(), DateFormat.LONG));
context.put("readableTermUnpublishDate", userTimeService.dateFormat(new Date(courseEndTime + (ONE_DAY_IN_MS * daysafter)), rb.getLocale(), DateFormat.LONG));
Expand Down

0 comments on commit 815939d

Please sign in to comment.