Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for non-gregorian calendars on iOS #57

Open
wongpeiyi opened this issue Mar 15, 2022 · 1 comment
Open

Support for non-gregorian calendars on iOS #57

wongpeiyi opened this issue Mar 15, 2022 · 1 comment
Labels

Comments

@wongpeiyi
Copy link

iOS user was experiencing a crash on opening datepicker:

NSRangeException
*** -[__NSArrayM objectAtIndex:]: index 9223372036854775807 beyond bounds [0 .. 1]

On some investigation the likely cause seems to be a non-Gregorian calendar setting (e.g. Buddhist), which changes the year from 2022 to something like 2565 BE

We are using v2.1.2 with a maxDate (which I suspect is causing the range exception)

I understand this is a rare use case, but wondering if there might be a simple fix that doesn't result in a crash

@wongpeiyi wongpeiyi added the bug label Mar 15, 2022
@skwasjer
Copy link
Owner

skwasjer commented Mar 15, 2022

There are ways to supporting it but requires reasonable work and specifically testing. It would need to be configurable through options and explicitly provided, or otherwise inferred from the locale/country (although this is less flexibel and limited through being coupled to this locale, also for representation/localization).
I am open to contributions.

To put you on track, eg. in Android, the Gregorian calendar is hardcoded:
https://github.com/skwasjer/skwas-cordova-plugin-datetimepicker/blob/main/src/android/DateTimePicker.java#L180

In iOS it is not hardcoded (IIRC), and you possibly can address it by setting the correct locale in the plugin options, but I cannot confirm this. Alternatively it could also be modified to either support locale or setting a specific calendar format:
https://stackoverflow.com/a/33373396

[edit] note that if you do not specify a locale in the options, it will use the user/device default

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants