fix webtoon es parse date (#5447)

This commit is contained in:
Riztard Lanthorn 2021-01-16 22:06:56 +07:00 committed by GitHub
parent 89e60709ef
commit f4c4760c6f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 2 deletions

View File

@ -5,7 +5,7 @@ ext {
extName = 'Webtoons'
pkgNameSuffix = 'all.webtoons'
extClass = '.WebtoonsFactory'
extVersionCode = 24
extVersionCode = 25
libVersion = '1.2'
}

View File

@ -77,4 +77,17 @@ class WebtoonsChineseTraditional : WebtoonsDefault("zh", "zh-hant", "zh_TW", Sim
class WebtoonsFr : WebtoonsDefault("fr", dateFormat = SimpleDateFormat("d MMM yyyy", Locale.FRENCH))
class WebtoonsEs : WebtoonsDefault("es", dateFormat = SimpleDateFormat("d-MMM-yyyy", Locale("es")))
class WebtoonsEs : WebtoonsDefault("es") {
// Android seems to be unable to parse es dates like Indonesian; we'll use a short hard-coded table
// instead.
private val dateMap: Array<String> = arrayOf(
"Ene", "Feb", "Mar", "Abr", "May", "Jun", "Jul", "Ago", "Sep", "Oct", "Nov", "Dic"
)
override fun chapterParseDate(date: String): Long {
val expr = Regex("""(\d+)-([a-z]{3})-(\d{4})""").find(date) ?: return 0
val (_, day, monthString, year) = expr.groupValues
val monthIndex = dateMap.indexOf(monthString)
return GregorianCalendar(year.toInt(), monthIndex, day.toInt()).time.time
}
}