react-native-datetimepicker / datetimepicker

React Native date & time picker component for iOS, Android and Windows
MIT License
2.47k stars 399 forks source link

Add support for Shamsi (Jalali) calendar type #16

Open MoKhajavi75 opened 5 years ago

MoKhajavi75 commented 5 years ago

Feature Request

Why it is needed

There are some other calendar types such as Shamsi (mostly used in Iran and Afghanistan). Currently, there is no complete and fully customizable component for Shamsi type which looks native.

Possible implementation

We can add it to the components (maybe via a calendarType prop. I also found this component for android which i can create a wrapper for it if it's needed. For iOS, AFAIK, we can customize the locale by locale prop which is already implemented (here) - [Source]

Code sample

<RNDateTimePicker calendarType='shamsi' />

Any ideas?

Swaagie commented 5 years ago

Thanks for reporting, seems like something we want to support. What I would like to make sure is that we support it for both platforms. We could wrap the android component you linked. Using calendarType to augment the locale behind the scenes seems doable, but I'm not sure that is the route we would want to take, but not sure I have a better alternative either. Using locale for Android to have it using the wrapper seems forceful as well.

MoKhajavi75 commented 5 years ago

So, I should search and make sure to find a suitable component for Android. Then i can start to write a wrapper. For iOS, can anyone confirm it, this:

dateFormatter.calendar = NSCalendar(identifier: NSCalendarIdentifierPersian)
dateFormatter.locale = NSLocale(localeIdentifier: "fa_IR")

is would do what we want?

SaeedZhiany commented 5 years ago

@Swaagie there is another Shamsi calendar implementation for android that looks very similar to the android default calendar. we can use it instead of the @MohamadKh75's linked library. however, it seems the latest commit is belonged to one year ago

SaeedZhiany commented 4 years ago

Also, I've found a react implementation for date picker it very customizable, It might be worth taking the time and implement a customizable date time picker for android from scratch by inspiring from that library. each existing libraries have annoying limitations and lack of maintenance. developing a general date picker in this react-native community could make sure that it will always up to date.

SaeedZhiany commented 4 years ago

I found another library that supports both gregorian and Jalali(shamsi) calendar at the same time. other solution is to replace the whole current android module with this library

MoKhajavi75 commented 4 years ago

@SaeedZhiany this is great! Can we replace the android module @Swaagie ?

SaeedZhiany commented 4 years ago

I figure out the library is an extension of this library and has added Jalali calendar support to it.

So I create an issue in @wdullaer's library and suggest to add DateTimePicker support. if the DateTimePicker can be added there, then we can add to @mohseneo's library and then finally we can add DateTimePicker android support in react-native (just like IOS).

It would be great if all you guys contribute.

SaeedZhiany commented 4 years ago

I have submitted a PR to @wdullaer's library and added Jalali calendar and font support to it. So we no longer need to @mohseneo' library (I merge his code with wdullaer's latest code on the master branch and fixed some bugs like force close when screen rotations that exist in Mohseneo's library as well) and we can use Wdullaer's library directly after the PR has been merged.

additionally, I added locale support for Jalali calendar (Persian and English locales that are mostly used locales in Iran)

MoKhajavi75 commented 4 years ago

@SaeedZhiany tnx 😍👌🏻

MoKhajavi75 commented 4 years ago

@SaeedZhiany Hey! I see your efforts here but it seems @wdullaer is away! Can you create a fork and then create a PR here?

SaeedZhiany commented 4 years ago

I prefer to not do that, because we may miss future PRs on @wdullaer's original repository. also I have not seen any active maintenance on this repository too. there are six PRs on this repository with no review, so I'm not sure this is good idea to add another one here and still have to waiting to review. (I'm not going to blame anyone, this is open-source world and no one has an obligation to work for free when they can earn money)

I prefer to wait to merge my PR on the other repository, because it may @wdullaer wants to have some changes on his repository that effects on the PR we want to submit here.

Meanwhile I recommend you to use react-native-modern-datepicker. it has not a native view on platforms but at least it supports Jalali calendar too.