From 7ddbac1f07dd6a836830c5454bcb3312216cf56b Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Fri, 23 Apr 2021 15:57:39 +0300 Subject: [PATCH] Made datetime in modscreen parsable for Java 7 phones And now date display is localized too which is nice --- changelog.md | 8 ++++---- .../com/unciv/ui/pickerscreens/ModManagementScreen.kt | 11 +++++++++-- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/changelog.md b/changelog.md index 887a920f94..90e49e215d 100644 --- a/changelog.md +++ b/changelog.md @@ -4,15 +4,15 @@ Added "Updated!" next to updated mods in mod management screen Added 'last updated time' and 'open Github page of mod' in mod management screen -Can no longer enter diplomacy screen for self, defeated and spectator civs through diplomacy overview screen +Cannot enter diplomacy screen for self, defeated and spectator civs through diplomacy overview Resolved #3817 - don't display resource requirements from uniques twice By SomeTroglodyte: -- Solves #3802 Mod translations don't appear in new game screen -- Modify choice of city to own the tiles acquired by a citadel - v2 -- Make city center unpillagable using a unique +- Mod translations now appear in new game screen +- Citadel tiles don't attach to razing cities if possible +- City center now unpillagable Parameterize civ-wide sight bonus - By SpacedOutChicken diff --git a/core/src/com/unciv/ui/pickerscreens/ModManagementScreen.kt b/core/src/com/unciv/ui/pickerscreens/ModManagementScreen.kt index 1101e00f07..9d8a59d00c 100644 --- a/core/src/com/unciv/ui/pickerscreens/ModManagementScreen.kt +++ b/core/src/com/unciv/ui/pickerscreens/ModManagementScreen.kt @@ -14,6 +14,8 @@ import com.unciv.models.ruleset.RulesetCache import com.unciv.models.translations.tr import com.unciv.ui.utils.* import com.unciv.ui.worldscreen.mainmenu.Github +import java.text.DateFormat +import java.text.SimpleDateFormat import java.time.LocalDateTime import java.time.format.DateTimeFormatter import java.util.* @@ -113,8 +115,13 @@ class ModManagementScreen: PickerScreen() { } if (updatedAt != "") { - val updateString = "{Updated}: " + LocalDateTime.parse(updatedAt, DateTimeFormatter.ISO_DATE_TIME) - .toLocalDate().toString() + // Everything under java.time is from Java 8 onwards, meaning older phones that use Java 7 won't be able to handle it :/ + // So we're forced to use ancient Java 6 classes instead of the newer and nicer LocalDateTime.parse :( + // Direct solution from https://stackoverflow.com/questions/2201925/converting-iso-8601-compliant-string-to-java-util-date + val df2 = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.US) // example: 2021-04-11T14:43:33Z + val date = df2.parse(updatedAt) + + val updateString = "{Updated}: " +DateFormat.getDateInstance(DateFormat.SHORT).format(date) modActionTable.add(updateString.toLabel()) } }