mirror of
https://github.com/SimpleMobileTools/Simple-Calendar.git
synced 2025-02-17 04:10:45 +01:00
some ics parsing datetimezone and repeat limit corrections
This commit is contained in:
parent
86c7b80514
commit
178fac5ad7
@ -139,10 +139,10 @@ class IcsParser {
|
|||||||
private fun parseDateTimeValue(value: String): Int {
|
private fun parseDateTimeValue(value: String): Int {
|
||||||
val edited = value.replace("T", "").replace("Z", "")
|
val edited = value.replace("T", "").replace("Z", "")
|
||||||
return if (edited.length == 14) {
|
return if (edited.length == 14) {
|
||||||
parseLongFormat(edited)
|
parseLongFormat(edited, value.endsWith("Z"))
|
||||||
} else {
|
} else {
|
||||||
val dateTimeFormat = DateTimeFormat.forPattern("yyyyMMdd")
|
val dateTimeFormat = DateTimeFormat.forPattern("yyyyMMdd")
|
||||||
dateTimeFormat.parseDateTime(edited).withHourOfDay(1).seconds()
|
dateTimeFormat.parseDateTime(edited).withZoneRetainFields(DateTimeZone.getDefault()).withHourOfDay(1).seconds()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -164,9 +164,10 @@ class IcsParser {
|
|||||||
|
|
||||||
private fun getDurationValue(duration: String, char: String): Int = Regex("[0-9]+(?=$char)").find(duration)?.value?.toInt() ?: 0
|
private fun getDurationValue(duration: String, char: String): Int = Regex("[0-9]+(?=$char)").find(duration)?.value?.toInt() ?: 0
|
||||||
|
|
||||||
private fun parseLongFormat(digitString: String): Int {
|
private fun parseLongFormat(digitString: String, useUTC: Boolean): Int {
|
||||||
val dateTimeFormat = DateTimeFormat.forPattern("yyyyMMddHHmmss")
|
val dateTimeFormat = DateTimeFormat.forPattern("yyyyMMddHHmmss")
|
||||||
return dateTimeFormat.parseDateTime(digitString).withZoneRetainFields(DateTimeZone.UTC).seconds()
|
val dateTimeZone = if (useUTC) DateTimeZone.UTC else DateTimeZone.getDefault()
|
||||||
|
return dateTimeFormat.parseDateTime(digitString).withZoneRetainFields(dateTimeZone).seconds()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun parseRepeatInterval(fullString: String): Int {
|
private fun parseRepeatInterval(fullString: String): Int {
|
||||||
@ -186,9 +187,10 @@ class IcsParser {
|
|||||||
} else if (key == INTERVAL) {
|
} else if (key == INTERVAL) {
|
||||||
val interval = value.toInt()
|
val interval = value.toInt()
|
||||||
val repeatInterval = frequencySeconds * interval
|
val repeatInterval = frequencySeconds * interval
|
||||||
if (count > 0)
|
if (count > 0) {
|
||||||
curRepeatLimit = curStart + count * repeatInterval
|
curRepeatLimit = curStart + count * repeatInterval
|
||||||
return repeatInterval
|
return repeatInterval
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return frequencySeconds
|
return frequencySeconds
|
||||||
|
Loading…
x
Reference in New Issue
Block a user