WPComics: Add `monthWords` and `yearWords` (#3477)

* WPComics: Add `monthWords` and `yearWords`

* Simplified month & year
This commit is contained in:
Smol Ame 2024-06-10 05:53:50 -07:00 committed by Draff
parent 88205d95b0
commit 4c4a178b9e
No known key found for this signature in database
GPG Key ID: E8A89F3211677653
2 changed files with 5 additions and 1 deletions

View File

@ -2,7 +2,7 @@ plugins {
id("lib-multisrc")
}
baseVersionCode = 5
baseVersionCode = 6
dependencies {
api(project(":lib:i18n"))

View File

@ -163,6 +163,8 @@ abstract class WPComics(
val minuteWords = listOf("minute", "phút")
val hourWords = listOf("hour", "giờ")
val dayWords = listOf("day", "ngày")
val monthWords = listOf("month", "tháng")
val yearWords = listOf("year", "năm")
val agoWords = listOf("ago", "trước")
return try {
@ -171,6 +173,8 @@ abstract class WPComics(
val calendar = Calendar.getInstance()
when {
yearWords.doesInclude(trimmedDate[1]) -> calendar.apply { add(Calendar.YEAR, -trimmedDate[0].toInt()) }
monthWords.doesInclude(trimmedDate[1]) -> calendar.apply { add(Calendar.MONTH, -trimmedDate[0].toInt()) }
dayWords.doesInclude(trimmedDate[1]) -> calendar.apply { add(Calendar.DAY_OF_MONTH, -trimmedDate[0].toInt()) }
hourWords.doesInclude(trimmedDate[1]) -> calendar.apply { add(Calendar.HOUR_OF_DAY, -trimmedDate[0].toInt()) }
minuteWords.doesInclude(trimmedDate[1]) -> calendar.apply { add(Calendar.MINUTE, -trimmedDate[0].toInt()) }