Made datetime in modscreen parsable for Java 7 phones

And now date display is localized too which is nice
This commit is contained in:
Yair Morgenstern 2021-04-23 15:57:39 +03:00
parent fb4a091635
commit 7ddbac1f07
2 changed files with 13 additions and 6 deletions

View File

@ -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

View File

@ -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())
}
}