File tree Expand file tree Collapse file tree 1 file changed +9
-8
lines changed
lib/src/main/kotlin/at/bitfire/vcard4android/contactrow Expand file tree Collapse file tree 1 file changed +9
-8
lines changed Original file line number Diff line number Diff line change @@ -88,22 +88,23 @@ object EventHandler : DataRowHandler() {
8888 */
8989 @VisibleForTesting
9090 internal fun parsePartialDate (dateString : String ): PartialDate ? {
91- var dateString = dateString // to allow modification
9291 return try {
9392 // convert Android partial date/date-time to vCard partial date/date-time so that it can be parsed by ez-vcard
9493
95- if (dateString.endsWith(' Z' )) {
94+ val withoutZ = if (dateString.endsWith(' Z' )) {
9695 // 'Z' is not supported for suffix in PartialDate, replace with actual offset
97- dateString = dateString.removeSuffix(" Z" ) + " +00:00"
96+ dateString.removeSuffix(" Z" ) + " +00:00"
97+ } else {
98+ dateString
9899 }
99100
100- val regex = " \\ .\\ d{3} " .toRegex()
101- if (dateString .contains(regex)) {
101+ val regex = " \\ .\\ d+ " .toRegex()
102+ if (withoutZ .contains(regex)) {
102103 // partial dates do not accept nanoseconds, so strip them if present
103- dateString = dateString .replace(regex, " " )
104- PartialDate .parse(dateString )
104+ val withoutNanos = withoutZ .replace(regex, " " )
105+ PartialDate .parse(withoutNanos )
105106 } else {
106- PartialDate .parse(dateString )
107+ PartialDate .parse(withoutZ )
107108 }
108109 } catch (_: IllegalArgumentException ) {
109110 // An error was thrown by PartialDate.parse
You can’t perform that action at this time.
0 commit comments