Skip to content

Commit

Permalink
Merge pull request DroidKaigi#766 from Corvus400/feature/fix_announce…
Browse files Browse the repository at this point in the history
…ments_day_and_month

🔧 Fix Fixed to display both day and month in two digits.
  • Loading branch information
takahirom authored Sep 26, 2022
2 parents d024cea + e58c186 commit 2e0cb57
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -265,10 +265,13 @@ private fun LocalDate.convertString(): String {
} else if (this.compareTo(yesterday) == 0) {
stringResource(Strings.announcement_content_header_title_yesterday)
} else {
"${this.year}/${this.month.value.toString().padStart(2, '0')}/${this.dayOfMonth}"
"${this.year}/${this.month.value.padDayOrMonth()}/${this.dayOfMonth.padDayOrMonth()}"
}
}

private fun Int.padDayOrMonth(): String =
this.toString().padStart(2, '0')

@Preview(showBackground = true)
@Composable
fun AnnouncementsPreview() {
Expand Down

0 comments on commit 2e0cb57

Please sign in to comment.