From 50f05855e6772dcb8b4bea83e5320b743bb45246 Mon Sep 17 00:00:00 2001 From: jeongjaino Date: Fri, 5 Jan 2024 17:23:31 +0900 Subject: [PATCH] =?UTF-8?q?[FEATURE]=20#81=20:=20=ED=98=84=EC=9E=AC=20?= =?UTF-8?q?=EB=82=A0=EC=A7=9C=EC=99=80=20=EB=A7=88=EA=B0=90=EA=B8=B0?= =?UTF-8?q?=ED=95=9C=20=EB=B9=84=EA=B5=90=ED=95=98=EB=8A=94=20=EB=A1=9C?= =?UTF-8?q?=EC=A7=81=20=EA=B5=AC=ED=98=84=20=EB=B0=8F=20=EB=A7=88=EA=B0=90?= =?UTF-8?q?=EA=B8=B0=ED=95=9C=20=EC=9E=90=EC=97=B0=EC=96=B4=EB=A1=9C=20?= =?UTF-8?q?=EB=B3=80=ED=99=98=ED=95=98=EB=8A=94=20=EB=A1=9C=EC=A7=81=20?= =?UTF-8?q?=EB=8F=84=EB=A9=94=EC=9D=B8=20=EB=AA=A8=EB=8D=B8=EB=A1=9C=20?= =?UTF-8?q?=EB=A7=88=EC=9D=B4=EA=B7=B8=EB=A0=88=EC=9D=B4=EC=85=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wap/wapp/core/model/survey/SurveyForm.kt | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/core/model/src/main/java/com/wap/wapp/core/model/survey/SurveyForm.kt b/core/model/src/main/java/com/wap/wapp/core/model/survey/SurveyForm.kt index d105c51a..164c298f 100644 --- a/core/model/src/main/java/com/wap/wapp/core/model/survey/SurveyForm.kt +++ b/core/model/src/main/java/com/wap/wapp/core/model/survey/SurveyForm.kt @@ -1,6 +1,8 @@ package com.wap.wapp.core.model.survey +import java.time.Duration import java.time.LocalDateTime +import java.time.format.DateTimeFormatter // 운영진이 등록하는 설문 모델 data class SurveyForm( @@ -17,4 +19,31 @@ data class SurveyForm( emptyList(), LocalDateTime.MIN, ) + + fun calculateDeadline(): String { + val currentDateTime = LocalDateTime.now() + val duration = Duration.between(currentDateTime, deadline) + + if (duration.toMinutes() < 60) { + val leftMinutes = duration.toMinutes().toString() + return leftMinutes + "분 후 마감" + } + + if (duration.toHours() < 24) { + val leftHours = duration.toHours().toString() + return leftHours + "시간 후 마감" + } + + if (duration.toDays() < 31) { + val leftDays = duration.toDays().toString() + return leftDays + "일 후 마감" + } + + return deadline.format(DateTimeFormatter.ofPattern("yyyy.MM.dd")) + " 마감" + } + + fun isAfterDeadline(): Boolean { + val currentDateTime = LocalDateTime.now() + return deadline.isAfter(currentDateTime) + } }