From 994074b6b514136d43ddc714b308cf19cf252a3c Mon Sep 17 00:00:00 2001 From: pmcphee77 <150798161+pmcphee77@users.noreply.github.com> Date: Tue, 2 Apr 2024 12:01:28 +0100 Subject: [PATCH] PI-2035: Fix date time issue (#3564) * PI-2035: Fix date time issue --- .../hmpps/data/generator/ContactGenerator.kt | 13 +++++++------ .../integrations/delius/overview/entity/Contact.kt | 8 ++++---- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/projects/manage-supervision-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/ContactGenerator.kt b/projects/manage-supervision-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/ContactGenerator.kt index 7cd73f9811..a20961264c 100644 --- a/projects/manage-supervision-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/ContactGenerator.kt +++ b/projects/manage-supervision-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/ContactGenerator.kt @@ -4,6 +4,7 @@ import uk.gov.justice.digital.hmpps.data.generator.ContactGenerator.DEFAULT_BORO import uk.gov.justice.digital.hmpps.data.generator.ContactGenerator.DEFAULT_PROVIDER import uk.gov.justice.digital.hmpps.data.generator.PersonGenerator.OVERVIEW import uk.gov.justice.digital.hmpps.data.generator.UserGenerator.USER +import uk.gov.justice.digital.hmpps.datetime.EuropeLondon import uk.gov.justice.digital.hmpps.integrations.delius.overview.entity.* import uk.gov.justice.digital.hmpps.integrations.delius.personalDetails.entity.ContactDocument import java.time.LocalDate @@ -39,7 +40,7 @@ object ContactGenerator { val PREVIOUS_APPT_CONTACT_ABSENT = generateContact( OVERVIEW, APPT_CT_1, - ZonedDateTime.of(LocalDateTime.now().minusDays(1), ZoneId.of("Europe/London")), + ZonedDateTime.of(LocalDateTime.now(EuropeLondon).minusDays(1), EuropeLondon), attended = false, action = BREACH_ENFORCEMENT_ACTION, startTime = null @@ -47,22 +48,22 @@ object ContactGenerator { val PREVIOUS_APPT_CONTACT = generateContact( OVERVIEW, APPT_CT_1, - ZonedDateTime.of(LocalDateTime.now().minusHours(1), ZoneId.of("Europe/London")) + ZonedDateTime.of(LocalDateTime.now(EuropeLondon).minusHours(1), EuropeLondon) ) val FIRST_NON_APPT_CONTACT = generateContact( OVERVIEW, OTHER_CT, - ZonedDateTime.of(LocalDateTime.now().plusHours(1), ZoneId.of("Europe/London")), + ZonedDateTime.of(LocalDateTime.now(EuropeLondon).plusHours(1), EuropeLondon), ) val FIRST_APPT_CONTACT = generateContact( OVERVIEW, APPT_CT_2, - ZonedDateTime.of(LocalDateTime.now().plusHours(2), ZoneId.of("Europe/London")) + ZonedDateTime.of(LocalDateTime.now(EuropeLondon).plusHours(2), EuropeLondon) ) val NEXT_APPT_CONTACT = generateContact( OVERVIEW, APPT_CT_3, - ZonedDateTime.of(LocalDateTime.now().plusHours(3), ZoneId.of("Europe/London")) + ZonedDateTime.of(LocalDateTime.now(EuropeLondon).plusHours(3), EuropeLondon) ) val CONTACT_DOCUMENT_1 = generateContactDocument( @@ -92,7 +93,7 @@ object ContactGenerator { ): ContactDocument { val doc = ContactDocument(contact) doc.id = IdGenerator.getAndIncrement() - doc.lastUpdated = ZonedDateTime.now().minusDays(1) + doc.lastUpdated = ZonedDateTime.now(EuropeLondon).minusDays(1) doc.alfrescoId = alfrescoId doc.name = name doc.personId = personId diff --git a/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/overview/entity/Contact.kt b/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/overview/entity/Contact.kt index 81ab290b3c..2aa35ce129 100644 --- a/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/overview/entity/Contact.kt +++ b/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/overview/entity/Contact.kt @@ -34,7 +34,7 @@ class Contact( val date: LocalDate = LocalDate.now(), @Column(name = "contact_start_time") - val startTime: ZonedDateTime? = ZonedDateTime.now(), + val startTime: ZonedDateTime? = ZonedDateTime.now(EuropeLondon), @Column(name = "rar_activity", length = 1) @Convert(converter = YesNoConverter::class) @@ -257,7 +257,7 @@ fun ContactRepository.getContact(personId: Long, contactId: Long): Contact = fun ContactRepository.firstAppointment( personId: Long, date: LocalDate = LocalDate.now(), - startTime: ZonedDateTime = ZonedDateTime.now() + startTime: ZonedDateTime = ZonedDateTime.now(EuropeLondon) ): Contact? = findUpComingAppointments( personId, date.format(DateTimeFormatter.ISO_LOCAL_DATE), @@ -267,7 +267,7 @@ fun ContactRepository.firstAppointment( fun ContactRepository.getUpComingAppointments( personId: Long, date: LocalDate = LocalDate.now(), - startTime: ZonedDateTime = ZonedDateTime.now() + startTime: ZonedDateTime = ZonedDateTime.now(EuropeLondon) ): List = findUpComingAppointments( personId = personId, dateNow = date.format(DateTimeFormatter.ISO_LOCAL_DATE), @@ -277,7 +277,7 @@ fun ContactRepository.getUpComingAppointments( fun ContactRepository.getPreviousAppointments( personId: Long, date: LocalDate = LocalDate.now(), - startTime: ZonedDateTime = ZonedDateTime.now() + startTime: ZonedDateTime = ZonedDateTime.now(EuropeLondon) ): List = findPreviousAppointments( personId = personId, dateNow = date.format(DateTimeFormatter.ISO_LOCAL_DATE),