You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
During unrelated testing of formatting time with the 12 hour / 24 hour time switch in iOS' Date & Time settings I noticed my app was hanging indefinitely, and I narrowed it down to this line in Iterators.swift:
guard let betweenOccurrences = Iterator.rruleContext?.evaluateScript("rule.between(new Date('\(beginDateJSON)'), new Date('\(untilDateJSON)'))").toArray() as? [Date] else {
return []
}
Typically I set my device's region to United States, but I changed it to United Kingdom. Even then it was fine, but if I turned the use 24 hour time switch to off (in the UK it defaults to on), the app has this problem with hanging.
Regardless of how big the gap between the two dates are, it seems to always hang. Memory doesn't build up, no error… I haven't really left it sitting to see if it ever escapes.
I think it can be easily resolved by setting a locale on the ISO8601DateFormatter in RRule.swift, e.g.:
It already sets the time zone to 0 seconds away from GMT so it seems it might as well prevent the locale of the device affecting the output.
I'm not clear on why it's doing this, but it might be because date formats are overridden by this "use 24 hour time" switch such according to whatever the default is for that region. So in the US the default is 12 hour time, so if you have a date format like "hh:mm a" then it will replace it with "HH:mm" if the switch is on. If you have a date format like "HH:mm" it seems to keep it as 24 hour time if your region's default is 12 hour time. But if your region defaults to 24 hour time, it looks like it might be the other way around. So if your format is "hh:mm a" it will not replace it, but if it's "HH:mm" then it will if the switch is turned off. I haven't tested this theory fully, but it seems to make sense.
The text was updated successfully, but these errors were encountered:
simonbromberg
changed the title
Iterator.rruleContext?.evaluateScript hangs with certain device date/time settings
Iterator.rruleContext?.evaluateScript hangs with certain device date/time regional/locale settings
Apr 19, 2018
During unrelated testing of formatting time with the 12 hour / 24 hour time switch in iOS' Date & Time settings I noticed my app was hanging indefinitely, and I narrowed it down to this line in Iterators.swift:
Typically I set my device's region to United States, but I changed it to United Kingdom. Even then it was fine, but if I turned the use 24 hour time switch to off (in the UK it defaults to on), the app has this problem with hanging.
Regardless of how big the gap between the two dates are, it seems to always hang. Memory doesn't build up, no error… I haven't really left it sitting to see if it ever escapes.
I think it can be easily resolved by setting a locale on the
ISO8601DateFormatter
in RRule.swift, e.g.:It already sets the time zone to 0 seconds away from GMT so it seems it might as well prevent the locale of the device affecting the output.
I'm not clear on why it's doing this, but it might be because date formats are overridden by this "use 24 hour time" switch such according to whatever the default is for that region. So in the US the default is 12 hour time, so if you have a date format like "hh:mm a" then it will replace it with "HH:mm" if the switch is on. If you have a date format like "HH:mm" it seems to keep it as 24 hour time if your region's default is 12 hour time. But if your region defaults to 24 hour time, it looks like it might be the other way around. So if your format is "hh:mm a" it will not replace it, but if it's "HH:mm" then it will if the switch is turned off. I haven't tested this theory fully, but it seems to make sense.
The text was updated successfully, but these errors were encountered: