Skip to content

Commit 2d97502

Browse files
authored
Merge pull request #517 from alwarnecke/ics-import-timezone-fix
Add default timezone to IcsImporter for timestamps not ending in Z (UTC)
2 parents 0dcc800 + 81d86a2 commit 2d97502

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

app/src/main/kotlin/org/fossify/calendar/helpers/IcsImporter.kt

+3-2
Original file line numberDiff line numberDiff line change
@@ -393,11 +393,11 @@ class IcsImporter(val activity: SimpleActivity) {
393393

394394
private fun getTimestamp(fullString: String): Long {
395395
return try {
396+
var timeZone = DateTimeZone.getDefault()
396397
when {
397398
fullString.startsWith(';') -> {
398399
// Ideally, we should parse BEGIN:VTIMEZONE and derive the timezone from there, but to get things working, let's assume TZID refers to one
399400
// of the known timezones
400-
var timeZone = DateTimeZone.getDefault()
401401
if (fullString.contains(':')) {
402402
val timeZoneId = fullString.substringAfter("%s=".format(TZID)).substringBefore(':')
403403
if (DateTimeZone.getAvailableIDs().contains(timeZoneId)) {
@@ -415,7 +415,8 @@ class IcsImporter(val activity: SimpleActivity) {
415415
Parser().parseDateTimeValue(value, timeZone)
416416
}
417417

418-
fullString.startsWith(":") -> Parser().parseDateTimeValue(fullString.substring(1).trim())
418+
fullString.startsWith(":") -> Parser().parseDateTimeValue(fullString.substring(1).trim(), timeZone)
419+
419420
else -> Parser().parseDateTimeValue(fullString)
420421
}
421422
} catch (e: Exception) {

0 commit comments

Comments
 (0)