Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adjust for BST when setting grant opening/closing dates #275

Merged
merged 1 commit into from
Apr 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@

import java.time.Instant;

import java.time.LocalDateTime;
import java.time.ZonedDateTime;
import java.util.UUID;

@Data
@@ -19,9 +19,9 @@ public class GetGrantAdvertPublishingInformationResponseDTO {

private UUID grantAdvertId;

private LocalDateTime openingDate;
private ZonedDateTime openingDate;

private LocalDateTime closingDate;
private ZonedDateTime closingDate;

private Instant firstPublishedDate;

Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@

import javax.persistence.*;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZonedDateTime;
import java.util.UUID;

@EntityListeners(AuditingEntityListener.class)
@@ -61,10 +61,10 @@ public class GrantAdvert extends BaseEntity {
private GrantAdmin lastUpdatedBy;

@Column(name = "opening_date")
private LocalDateTime openingDate;
private ZonedDateTime openingDate;

@Column(name = "closing_date")
private LocalDateTime closingDate;
private ZonedDateTime closingDate;

@Column(name = "first_published_date")
private Instant firstPublishedDate;
Original file line number Diff line number Diff line change
@@ -574,12 +574,14 @@ private void updateGrantAdvertApplicationDates(final GrantAdvert grantAdvert) {
int[] closingResponse = Arrays.stream(closingDateQuestion.getMultiResponse()).mapToInt(Integer::parseInt)
.toArray();

// build LocalDateTimes
LocalDateTime openingDate = LocalDateTime
.of(openingResponse[2], openingResponse[1], openingResponse[0], openingResponse[3], openingResponse[4]);

LocalDateTime closingDate = LocalDateTime
.of(closingResponse[2], closingResponse[1], closingResponse[0], closingResponse[3], closingResponse[4]);
// build ZonedDateTimes
ZonedDateTime openingDate = LocalDateTime
.of(openingResponse[2], openingResponse[1], openingResponse[0], openingResponse[3], openingResponse[4])
.atZone(ZoneId.of("Europe/London"));

ZonedDateTime closingDate = LocalDateTime
.of(closingResponse[2], closingResponse[1], closingResponse[0], closingResponse[3], closingResponse[4])
.atZone(ZoneId.of("Europe/London"));

// set dates on advert
grantAdvert.setOpeningDate(openingDate);
Original file line number Diff line number Diff line change
@@ -35,6 +35,8 @@
import javax.validation.Validator;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.util.Collections;
import java.util.Set;
import java.util.UUID;
@@ -449,9 +451,9 @@ class getAdvertPublishInformation {

private final Instant dateTimeInput = Instant.parse("2022-01-01T00:00:00.00Z");

private final LocalDateTime openingDate = LocalDateTime.parse("2022-01-01T00:00:00.00");
private final ZonedDateTime openingDate = LocalDateTime.parse("2022-01-01T00:00:00.00").atZone(ZoneId.of("Europe/London"));

private final LocalDateTime closingDate = LocalDateTime.parse("2022-01-01T00:00:00.00");
private final ZonedDateTime closingDate = LocalDateTime.parse("2022-01-01T00:00:00.00").atZone(ZoneId.of("Europe/London"));

private final Instant firstPublishedDate = dateTimeInput;

Original file line number Diff line number Diff line change
@@ -738,13 +738,15 @@ class publishAdvert {
.id("grantApplicationOpenDate").seen(true)
.multiResponse(new String[] { "10", "12", "2022", "00", "01" }).build();

final LocalDateTime openingDate = LocalDateTime.of(2022, 12, 10, 0, 1);
final ZonedDateTime openingDate = LocalDateTime.of(2022, 12, 10, 0, 1)
.atZone(ZoneId.of("Europe/London"));

final GrantAdvertQuestionResponse response5 = GrantAdvertQuestionResponse.builder()
.id("grantApplicationCloseDate").seen(true)
.multiResponse(new String[] { "10", "12", "2023", "23", "59" }).build();

final LocalDateTime closingDate = LocalDateTime.of(2023, 12, 10, 23, 59);
final ZonedDateTime closingDate = LocalDateTime.of(2023, 12, 10, 23, 59)
.atZone(ZoneId.of("Europe/London"));;

final GrantAdvertQuestionResponse response6 = GrantAdvertQuestionResponse.builder().id("grantTotalAwardAmount")
.response("1000000").seen(true).build();
@@ -1223,13 +1225,15 @@ class scheduleGrantAdvert {
.id("grantApplicationOpenDate").seen(true).multiResponse(new String[] { "10", "12", "2022", "0", "1" })
.build();

final LocalDateTime openingDate = LocalDateTime.of(2022, 12, 10, 0, 1);
final ZonedDateTime openingDate = LocalDateTime.of(2022, 12, 10, 0, 1)
.atZone(ZoneId.of("Europe/London"));

final GrantAdvertQuestionResponse response5 = GrantAdvertQuestionResponse.builder()
.id("grantApplicationCloseDate").seen(true)
.multiResponse(new String[] { "10", "12", "2023", "23", "59" }).build();

final LocalDateTime closingDate = LocalDateTime.of(2023, 12, 10, 23, 59);
final ZonedDateTime closingDate = LocalDateTime.of(2023, 12, 10, 23, 59)
.atZone(ZoneId.of("Europe/London"));

final GrantAdvertPageResponse datesPage = GrantAdvertPageResponse.builder().id("1")
.status(GrantAdvertPageResponseStatus.COMPLETED).questions(List.of(response4, response5)).build();