Skip to content

Commit

Permalink
PI-2035: Fix date time issue (#3564)
Browse files Browse the repository at this point in the history
* PI-2035: Fix date time issue
  • Loading branch information
pmcphee77 authored Apr 2, 2024
1 parent f0f2f29 commit 994074b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -39,30 +40,30 @@ 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
)
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(
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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),
Expand All @@ -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<Contact> = findUpComingAppointments(
personId = personId,
dateNow = date.format(DateTimeFormatter.ISO_LOCAL_DATE),
Expand All @@ -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<Contact> = findPreviousAppointments(
personId = personId,
dateNow = date.format(DateTimeFormatter.ISO_LOCAL_DATE),
Expand Down

0 comments on commit 994074b

Please sign in to comment.