in api/src/main/scala/com/gu/footballtimemachine/ApiLambda.scala [99:114]
def setDate(request: ApiGatewayRequest): ApiGatewayResponse = {
val startDate = ZonedDateTime.parse(request.queryStringParameters.get("startDate")).toInstant.toEpochMilli
val offset = System.currentTimeMillis() - startDate
s3Client.putObject(
PutObjectRequest.builder().bucket(bucket).key("startDate").build(),
RequestBody.fromString(startDate.toString, StandardCharsets.UTF_8))
s3Client.putObject(
PutObjectRequest.builder().bucket(bucket).key("offset").build(),
RequestBody.fromString(offset.toString, StandardCharsets.UTF_8))
val speed = request.queryStringParamMap.getOrElse("speed", 5)
s3Client.putObject(PutObjectRequest.builder().bucket(bucket).key("speed").build(), RequestBody.fromString(speed.toString, StandardCharsets.UTF_8))
val date = ZonedDateTime.ofInstant(Instant.ofEpochMilli(computeTime), ZoneId.of("Europe/London"))
ApiGatewayResponse(200, Map.empty, body = s"""{"currentDate":"${date.format(DateTimeFormatter.ISO_OFFSET_DATE_TIME)}"}""")
}