From c0d9d393bfb545f7a6728700ffd6c6ce430d07e9 Mon Sep 17 00:00:00 2001 From: pervertkirito Date: Thu, 9 May 2019 18:10:42 +0800 Subject: [PATCH] fix parseChapterDate (#1096) * fix parseChapterDate * Update build.gradle * Update Mangahere.kt Ah sorry my bad --- src/en/mangahere/build.gradle | 2 +- .../extension/en/mangahere/Mangahere.kt | 29 +++++++++++++++---- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/src/en/mangahere/build.gradle b/src/en/mangahere/build.gradle index c9a48eda8..61240ef78 100644 --- a/src/en/mangahere/build.gradle +++ b/src/en/mangahere/build.gradle @@ -5,7 +5,7 @@ ext { appName = 'Tachiyomi: Mangahere' pkgNameSuffix = 'en.mangahere' extClass = '.Mangahere' - extVersionCode = 8 + extVersionCode = 9 libVersion = '1.2' } diff --git a/src/en/mangahere/src/eu/kanade/tachiyomi/extension/en/mangahere/Mangahere.kt b/src/en/mangahere/src/eu/kanade/tachiyomi/extension/en/mangahere/Mangahere.kt index a4e82fff8..4ef544c80 100644 --- a/src/en/mangahere/src/eu/kanade/tachiyomi/extension/en/mangahere/Mangahere.kt +++ b/src/en/mangahere/src/eu/kanade/tachiyomi/extension/en/mangahere/Mangahere.kt @@ -161,11 +161,28 @@ class Mangahere : ParsedHttpSource() { } private fun parseChapterDate(date: String): Long { - return try { - SimpleDateFormat("MMM dd,yyyy", Locale.ENGLISH).parse(date).time - } catch (e: ParseException) { - 0L - } + return if ("Today" in date || " ago" in date){ + Calendar.getInstance().apply { + set(Calendar.HOUR_OF_DAY, 0) + set(Calendar.MINUTE, 0) + set(Calendar.SECOND, 0) + set(Calendar.MILLISECOND, 0) + }.timeInMillis + } else if ("Yesterday" in date) { + Calendar.getInstance().apply { + add(Calendar.DATE, -1) + set(Calendar.HOUR_OF_DAY, 0) + set(Calendar.MINUTE, 0) + set(Calendar.SECOND, 0) + set(Calendar.MILLISECOND, 0) + }.timeInMillis + } else { + try { + SimpleDateFormat("MMM dd,yyyy", Locale.ENGLISH).parse(date).time + } catch (e: ParseException) { + 0L + } + } } override fun pageListParse(document: Document): List { @@ -318,4 +335,4 @@ class Mangahere : ParsedHttpSource() { Genre("Lolicon", 36) ) -} \ No newline at end of file +}