-
Notifications
You must be signed in to change notification settings - Fork 1
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
Feature/jaino/#140 #146
Feature/jaino/#140 #146
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
package com.wap.wapp.core.model.survey | ||
|
||
import java.time.Duration | ||
import java.time.LocalDateTime | ||
import java.time.ZoneId | ||
import java.time.format.DateTimeFormatter | ||
|
||
/* | ||
ํ์์ด ์์ฑํ๋ ์ค๋ฌธ ๋ชจ๋ธ | ||
|
@@ -15,4 +18,33 @@ data class Survey( | |
val content: String, | ||
val surveyAnswerList: List<SurveyAnswer>, | ||
val surveyedAt: LocalDateTime, | ||
) | ||
) { | ||
fun calculateSurveyedAt(): String { | ||
val currentDateTime = LocalDateTime.now(TIME_ZONE_SEOUL) | ||
val duration = Duration.between(surveyedAt, currentDateTime) | ||
|
||
if (duration.toMinutes() == 0L) { | ||
return "๋ฐฉ๊ธ" | ||
} else 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 + "์ผ ์ ์์ฑ" | ||
} | ||
Comment on lines
+26
to
+41
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ์ฌ๊ธฐ ๋งค์ง๋๋ฒ๋ค์ ์์ํ ์ํฌ ๋ง ํ ๊น์ ...? ๋ง์ฝ ํ๋ค๋ฉด ๋ค๋ฅธ ๊ณณ๋ค๋ ๋ค ํ๊ธด ํด์ผ ํ ํ ๋ฐ .. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ํ๋ค๋ฉด companionObject ๋ด์์ ํด์ผํ๋๋ฐ ๋ฌธ๋งฅ์ ์ดํด๊ฐ ๋ผ์ |
||
|
||
return surveyedAt.format(yyyyMMddFormatter) + " ์์ฑ" | ||
} | ||
|
||
companion object { | ||
val yyyyMMddFormatter = DateTimeFormatter.ofPattern("yyyy.MM.dd") | ||
val TIME_ZONE_SEOUL = ZoneId.of("Asia/Seoul") | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
๋ฐฉ๊ธ ์ฌ๋ฐ๋๋ฐ์ ์งํธ์ ใ ใ ใ ใ