datetimepicker icon indicating copy to clipboard operation
datetimepicker copied to clipboard

Add support for Shamsi (Jalali) calendar type

Open MoKhajavi75 opened this issue 6 years ago • 11 comments

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?

MoKhajavi75 avatar Aug 12 '19 11:08 MoKhajavi75

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.

Swaagie avatar Aug 13 '19 08:08 Swaagie

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?

MoKhajavi75 avatar Aug 13 '19 09:08 MoKhajavi75

@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 avatar Sep 04 '19 12:09 SaeedZhiany

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 avatar Sep 15 '19 14:09 SaeedZhiany

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

SaeedZhiany avatar Sep 18 '19 07:09 SaeedZhiany

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

MoKhajavi75 avatar Sep 18 '19 07:09 MoKhajavi75

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 avatar Sep 18 '19 07:09 SaeedZhiany

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)

SaeedZhiany avatar Oct 07 '19 16:10 SaeedZhiany

@SaeedZhiany tnx 😍👌🏻

MoKhajavi75 avatar Oct 07 '19 20:10 MoKhajavi75

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

MoKhajavi75 avatar Dec 17 '19 16:12 MoKhajavi75

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.

SaeedZhiany avatar Dec 18 '19 04:12 SaeedZhiany