Skip to content

Commit

Permalink
Fixing accessDate string not being parsed correctly if it only consis…
Browse files Browse the repository at this point in the history
…ted of yyyy-MM-dd and had no time component. Closes #135

Upping versionCode to 76
  • Loading branch information
Dima-Android committed Jun 18, 2024
1 parent 89ab4a5 commit ca9e8bc
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ val iso8601DateFormatV2: SimpleDateFormat
timeZone = TimeZone.getTimeZone("UTC")
}

val fullDateWithDashesUtc: SimpleDateFormat
get() = SimpleDateFormat("yyyy-MM-dd", Locale.getDefault()).apply {
timeZone = TimeZone.getTimeZone("UTC")
}

val deadlineTimeFormat: SimpleDateFormat
get() = SimpleDateFormat("EEEE MMM d, h:mm a", Locale.getDefault())

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import org.zotero.android.database.objects.RItem
import org.zotero.android.database.requests.items
import org.zotero.android.files.FileStore
import org.zotero.android.helpers.formatter.dateFormatItemDetails
import org.zotero.android.helpers.formatter.fullDateWithDashesUtc
import org.zotero.android.helpers.formatter.iso8601DateFormatV2
import org.zotero.android.helpers.formatter.sqlFormat
import org.zotero.android.screens.itemdetails.data.ItemDetailCreator
Expand Down Expand Up @@ -260,7 +261,11 @@ object ItemDetailDataCreator {

if (key == FieldKeys.Item.accessDate) {
if (value.isNotEmpty()) {
val date = iso8601DateFormatV2.parse(value)!!
val date: Date = try {
iso8601DateFormatV2.parse(value)!!
} catch (e: Exception) {
fullDateWithDashesUtc.parse(value)!!
}
additionalInfo = mapOf(
ItemDetailField.AdditionalInfoKey.formattedDate to dateFormatItemDetails().format(date),
ItemDetailField.AdditionalInfoKey.formattedEditDate to sqlFormat.format(date))
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/BuildConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ object BuildConfig {
const val compileSdkVersion = 34
const val targetSdk = 33

val versionCode = 75 // Must be updated on every build
val versionCode = 76 // Must be updated on every build
val version = Version(
major = 1,
minor = 0,
Expand Down

0 comments on commit ca9e8bc

Please sign in to comment.