Skip to content
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

kuring-136 바뀐 학과별 공지 날짜 포맷 대응 #97

Merged
merged 1 commit into from
Feb 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ package com.ku_stacks.ku_ring.notice.mapper

import com.ku_stacks.ku_ring.local.entity.NoticeEntity
import com.ku_stacks.ku_ring.remote.notice.response.DepartmentNoticeResponse
import java.text.SimpleDateFormat
import java.util.Locale


fun List<DepartmentNoticeResponse>.toEntityList(shortName: String, startDate: String) =
Expand All @@ -14,24 +12,16 @@ fun List<DepartmentNoticeResponse>.toEntityList(shortName: String, startDate: St
* TODO: NPE 대신 빈 문자열을 넣도록 수정
*/
fun DepartmentNoticeResponse.toNoticeEntity(shortName: String, startDate: String): NoticeEntity {
val dashRemovedPostedDate = removeDashFromDate(postedDate!!)
return NoticeEntity(
articleId = articleId!!,
category = category!!,
department = shortName,
subject = subject!!,
postedDate = dashRemovedPostedDate,
postedDate = postedDate!!,
url = url!!,
isNew = (dashRemovedPostedDate >= startDate),
isNew = (postedDate!! >= startDate),
isRead = false,
isSaved = false,
isReadOnStorage = false,
)
}

private fun removeDashFromDate(dashSeparatedDate: String): String {
val inputFormatter = SimpleDateFormat("yyyy-MM-dd", Locale.getDefault())
val outputFormatter = SimpleDateFormat("yyyyMMdd", Locale.getDefault())
val date = inputFormatter.parse(dashSeparatedDate)
return outputFormatter.format(date)
}
Loading