X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fajax%2FGetTimesAjaxPage.kt;h=9310786e51f402cdbb05fcb27eb2f6fccc515f7c;hb=2ee758b50d597bfd1ec01db720e5b050027c80ea;hp=358003a0c80a3362b35606194e5136d6f6f3f55a;hpb=69af5a8e6bc69347e3979fd2f351ead5fcfb98fb;p=Sone.git diff --git a/src/main/kotlin/net/pterodactylus/sone/web/ajax/GetTimesAjaxPage.kt b/src/main/kotlin/net/pterodactylus/sone/web/ajax/GetTimesAjaxPage.kt index 358003a..9310786 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/ajax/GetTimesAjaxPage.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/ajax/GetTimesAjaxPage.kt @@ -8,15 +8,19 @@ import net.pterodactylus.sone.utils.parameters import net.pterodactylus.sone.web.WebInterface import net.pterodactylus.sone.web.page.FreenetRequest import java.text.SimpleDateFormat +import java.util.TimeZone /** * Ajax page that returns a formatted, relative timestamp for replies or posts. */ class GetTimesAjaxPage(webInterface: WebInterface, private val timeTextConverter: TimeTextConverter, - private val l10nFilter: L10nFilter) : JsonPage("getTimes.ajax", webInterface) { + private val l10nFilter: L10nFilter, + timeZone: TimeZone) : JsonPage("getTimes.ajax", webInterface) { - private val dateTimeFormatter = SimpleDateFormat("MMM d, yyyy, HH:mm:ss") + private val dateTimeFormatter = SimpleDateFormat("MMM d, yyyy, HH:mm:ss").apply { + this.timeZone = timeZone + } override fun needsFormPassword() = false override fun requiresLogin() = false @@ -36,7 +40,9 @@ class GetTimesAjaxPage(webInterface: WebInterface, id to jsonObject( "timeText" to l10nFilter.format(null, timeText.l10nText, emptyMap()), "refreshTime" to timeText.refreshTime / 1000, - "tooltip" to dateTimeFormatter.format(time)) + "tooltip" to synchronized(dateTimeFormatter) { + dateTimeFormatter.format(time) + }) }.forEach { this@jsonObject.put(it.first, it.second) } }