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

Add support for Shamsi (Jalali) calendar type #16

Open
MoKhajavi75 opened this issue Aug 12, 2019 · 11 comments
Open

Add support for Shamsi (Jalali) calendar type #16

MoKhajavi75 opened this issue Aug 12, 2019 · 11 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@MoKhajavi75
Copy link

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 MoKhajavi75 changed the title Support Shamsi calendar type Add support for Shamsi calendar type Aug 12, 2019
@MoKhajavi75 MoKhajavi75 changed the title Add support for Shamsi calendar type Add support for Shamsi (Jalali) calendar type Aug 12, 2019
@Swaagie Swaagie added enhancement New feature or request good first issue Good for newcomers labels Aug 13, 2019
@Swaagie
Copy link
Collaborator

Swaagie commented Aug 13, 2019

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 Swaagie added help wanted Extra attention is needed and removed good first issue Good for newcomers labels Aug 13, 2019
@MoKhajavi75
Copy link
Author

MoKhajavi75 commented Aug 13, 2019

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
Copy link
Contributor

SaeedZhiany commented Sep 4, 2019

@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
Copy link
Contributor

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
Copy link
Contributor

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
Copy link
Author

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

@SaeedZhiany
Copy link
Contributor

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
Copy link
Contributor

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
Copy link
Author

@SaeedZhiany tnx 😍👌🏻

@MoKhajavi75
Copy link
Author

@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
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants