revert removed harcode date-parse (#4994)

it seems normal dateFormat doesnt work in some cases(android/device/android lower than 10/other cause)
This commit is contained in:
Riztard Lanthorn 2020-12-02 19:42:18 +07:00 committed by GitHub
parent ae594543bd
commit 4f36aef73d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 2 deletions

View File

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

View File

@ -3,6 +3,7 @@ package eu.kanade.tachiyomi.extension.all.webtoons
import eu.kanade.tachiyomi.source.Source
import eu.kanade.tachiyomi.source.SourceFactory
import java.text.SimpleDateFormat
import java.util.GregorianCalendar
import java.util.Locale
class WebtoonsFactory : SourceFactory {
@ -51,8 +52,21 @@ class WebtoonsFactory : SourceFactory {
class WebtoonsEnglish : WebtoonsDefault("en")
class WebtoonsIndonesian : WebtoonsDefault("id", dateFormat = SimpleDateFormat("yyyy MMM dd", Locale("id"))) {
class WebtoonsIndonesian : WebtoonsDefault("id") {
override val name: String = "Webtoons.com (Indonesian)"
// Android seems to be unable to parse Indonesian dates; we'll use a short hard-coded table
// instead.
private val dateMap: Array<String> = arrayOf(
"Jan", "Feb", "Mar", "Apr", "Mei", "Jun", "Jul", "Agu", "Sep", "Okt", "Nov", "Des"
)
override fun chapterParseDate(date: String): Long {
val expr = Regex("""(\d{4}) ([A-Z][a-z]{2}) (\d+)""").find(date) ?: return 0
val (_, year, monthString, day) = expr.groupValues
val monthIndex = dateMap.indexOf(monthString)
return GregorianCalendar(year.toInt(), monthIndex, day.toInt()).time.time
}
}
class WebtoonsThai : WebtoonsDefault("th", dateFormat = SimpleDateFormat("d MMM yyyy", Locale("th")))