Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into mod/#148-post-api-…
Browse files Browse the repository at this point in the history
…dto-mod
  • Loading branch information
Roel4990 committed Jan 23, 2025
2 parents e4e8907 + e1940c8 commit c3cb949
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,22 @@
package com.spoony.spoony.core.util.extension

import java.time.LocalDateTime
import java.time.format.DateTimeFormatter
import java.time.format.DateTimeParseException
import java.util.Locale

fun String?.toValidHexColor(): String =
if (this != null && Regex("^[0-9A-Fa-f]{6}$").matches(this)) this else "FFFFFF"

fun String.formatToYearMonthDay(): String? {
return try {
val inputFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSSSS", Locale.getDefault())
val outputFormatter = DateTimeFormatter.ofPattern("yyyy년 M월 d일", Locale.getDefault())
val dateTime = LocalDateTime.parse(this, inputFormatter)
dateTime.format(outputFormatter)
} catch (e: DateTimeParseException) {
null
} catch (e: Exception) {
null
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import com.spoony.spoony.core.designsystem.component.tag.IconTag
import com.spoony.spoony.core.designsystem.component.topappbar.TagTopAppBar
import com.spoony.spoony.core.designsystem.theme.SpoonyAndroidTheme
import com.spoony.spoony.core.state.UiState
import com.spoony.spoony.core.util.extension.formatToYearMonthDay
import com.spoony.spoony.core.util.extension.hexToColor
import com.spoony.spoony.core.util.extension.toValidHexColor
import com.spoony.spoony.domain.entity.CategoryEntity
Expand Down Expand Up @@ -180,7 +181,7 @@ fun PlaceDetailRoute(
userRegion = userProfile.userRegion,
photoUrlList = data.photoUrlList.toImmutableList(),
category = data.category,
date = data.date,
date = data.date.formatToYearMonthDay(),
placeAddress = data.placeAddress,
placeName = data.placeName,
isScooped = state.isScooped,
Expand All @@ -205,7 +206,7 @@ private fun PlaceDetailScreen(
userRegion: String,
photoUrlList: ImmutableList<String>,
category: CategoryEntity,
date: String,
date: String?,
placeAddress: String,
placeName: String,
isScooped: Boolean,
Expand Down Expand Up @@ -275,7 +276,7 @@ private fun PlaceDetailScreen(
Spacer(modifier = Modifier.height(8.dp))

Text(
text = date,
text = date ?: "",
style = SpoonyAndroidTheme.typography.caption1m,
color = SpoonyAndroidTheme.colors.gray400
)
Expand Down

0 comments on commit c3cb949

Please sign in to comment.