-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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 Hijri or Jalali or other international calendar in datepicker #2519
Comments
There's no datepicker in material2. |
I just saw datepicker on material2 feature status: https://github.com/angular/material2#feature-status |
The problem with datepicker, as mentioned in its issue, is that there are no specs(for desktop version anyway) in material design for it.. so until google designers create those, there won't be no official date/timepicker implementation. Sadly. But I'm pretty sure that once the spec is done, internationalization will be taken into account. |
Internationalization date conversion may not affect visual design of datepicker. It just refer to how cells arrange according to the native calendar rules, mainly the same functions as currently exist in dateUtil, but with native alternative principals. About the visual customization, task already has been done gracefully in $mdDateLocale. |
We're designing the datepicker now. We likely will only be able to support the Gregorian calendar in the initial version, but it's worth thinking about in the design. |
At the moment it may not important to support any special native calendar. The important point about this feature is to make the logic of date conversion 'injectable'. Then every folk will know how to implement their native conversion logic providers. Although I had some suggestions above, but as a designer, you know better how to construct the structure. Thanks Jeremy, for taking it into account and for your grate project. |
I'll have a design doc to share shortly, it would be great if you could take a look and let me know if you think the design is flexible enough to support this. |
of course, it would be my pleasure. |
@araselahi design doc is now available: https://docs.google.com/document/d/1RwPFESCbSSLMSDqxWo7jg4UUpGJTrXX6p5wYlb9pmNc/preview |
I have just seen the notification in my email. I will get back to you soon. |
@mmalerba 'CalendarLocale injectable' and 'Internationalization' sections currently include the definition only about the word translation and visual parsing and formatting but not other nationality date conversion logic. In other calendars, days calculation completely different from Gregorian. So I guess we need all the logic in dateUtil.js such as getFirstDateOfMonth, getNumberOfDaysInMonth and so on could be replaceable according to the other international calendar to determine how the days to be rendered on date picker. I think with this suggested feature, it would be a magic date picker for other folks. I am not sure the new SimpleDate data type could support other international calendar date because it is still subset of Gregorian calendar date. Am I right? |
@araselahi I'd like to find some way to allow using moment.js objects instead of |
As @araselahi mentioned, it is not a matter of translation from English to another language. |
@peymanebrahimi it completely depends on how to implement Moment.js. If the output of configured Moment.js object was rendered on the final date picker surface as @mmalerba designed for, that would be great. Please check it out: |
@mmalerba does what we have now actually support different calendars, or are there assumptions about the Gregorian calendar baked in? |
I think we still have some assumptions baked in, but it should be easy enough to change them to settings in the |
@mmalerba with |
@peymanebrahimi has been working on a Jalali adapter #5972 (comment), you may want to consider collaborating with him. Currently the best documentation is just the JSDoc on the You can also use the Sorry it doesn't have better documentation yet... I need to work on that. @araselahi |
Have you thought of supporting Julian Day Numbers for internal conversions from one calendar format to another? There are already JS libraries around that could possibly be used for the conversions (e.g., http://npmjs.com/package/moonbeams). I am interested in developing the following features:
|
@tobiasschweizer choosing a different precision is tracked by #4853, this is something we plan to add BCE dates and a Julian calendar are not features we plan to add to Angular Material, but they are features that we want enable via a custom |
@mmalerba Thank you very much for the explanation! Let me have a look at As far as I understood, |
@tobiasschweizer Yep, that's correct. I've been meaning to write a guide on creating a custom |
Ah I see, I had not heard about Julian Day Number before. In that case I think your proposal sounds reasonable. Would the Another thing to consider is the parse and display formats. We allow the user to provide mappings for the formats needed by the datepicker via the |
I really like your design that separates the UI-component (datepicker) from a concrete implementation of a calendar (currently JS Date object and MomentJS) using This abstraction greatly enhances the re-usability of the UI component. However, I also see things that are actually calendar specific like the distinction between BCE and CE dates and only make sense for the Gregorian and the Julian calendar.
Yes,
Although we aim to be as generic as possible, the UI component might be limited to calendars that work with a concept of years, months, and days.
I think localization and format information has to be provided for each implementation of How shall we proceed? I would like to work on I think Another thing to keep in mind is the precision. A precision can by expressed using two JDNs (see http://www.knora.org/documentation/manual/rst/knora-ontologies/knora-base.html#datevalue, https://github.com/dhlab-basel/Knora/blob/cc53ef8cd072b7c9c53c7e5b3ab3a92c497b3038/webapi/src/main/scala/org/knora/webapi/util/DateUtilV1.scala). If the two numbers are equal the precision is day. Month precison would be from the first day of the month to the last and the same logic applies to the year. Periods may be expressed by simply having two datepickers, i.e. two dates that might have different precisions. |
I am having a look at the abstract methods of I am quite sure I forgot some of the methods or misunderstood some of them, please feel free to correct me ;-)
|
I think each implementation or subclass of For When serializing the date, the calendar information has to go somewhere (group 4), it could be omitted for Gregorian. For the year (group 1), BCE dates could be tricky. |
Apologies for the slow response. I agree with what you've outlined above. I think this is a cool idea, it would be great for people who need a more robust solution for dealing with multiple calendars. Here's some thoughts & rationale for some of the decisions:
Yes this does limit us to calendars that use years, months, and days. Though I think that should cover the vast majority of calendars people would want to use with the datepicker. Though one of the things I don't like about these various
I used "date" to stay consistent with what javascript does and avoid confusion with days of the week. Though I agree its confusing in its own way. I would be ok replacing the "date" APIs with "dayOfMonth".
The idea was that the name variant could be used in situations where the string representation was more than just the number. For example in Japanese maybe someone would want to include the year kanji: "2017年". Though as I mentioned above I don't like how these "-name" APIs mix in formatting logic. It might be better to move to something like Do you want to start a repo for it? If you run into flexibility issues with the |
@mmalerba No worries! Thank you very much for your detailed response. I have started implementing I also still need to figure out how date manipulations work (increasing and decreasing year, month, and day). I have already added some simple conversion tests. The current implementation will still change a lot, but I hope that there will be a proof of concept soon. I did not bother with precision yet (every date has an exact start and end so far: day precision), also I did not care about string formats yet. I think a lot of this should be handled in the implementation of In which repo would the implementation of |
Hmm I think its up to you how you want to structure it. You could put it in the same repo but make a separate npm package from the core calendar logic if you want to make the calendar logic available to people who aren't using Angular. The angular specific stuff would probably consist of the date adapter, a set of formats, and a module or 2 that people can import to easily set up the providers. This is similar to what we do for the |
I think it would make sense to put the I forked the Angular Material 2 repo. Shall I implement How shall I deal with the Maybe it would make things easier if we could talk briefly. However, I suppose your are located in the US and I am here in Europe (time diff.). |
@mmalerba I created a new branch on my forked repo from angular/material2: https://github.com/dhlab-basel/material2/tree/datepicker-datadapter-jdnconvcal I am struggling with |
@tobiasschweizer I can set up some time to do a Hangouts conversation if you like. Shoot me an email: mmalerba@google.com |
@mmalerba As soon as a build with our merged PR #9639 is available, I will make a proof of concept in my repo https://github.com/dhlab-basel/JDNConvertibleCalendarDateAdapter with a custom header so that the user can switch between Gregorian and Julian calendar formats. https://github.com/dhlab-basel/JDNConvertibleCalendar will have to be extended too so that more calendar formats are supported in the future. |
I think it is already there angular/material-builds@d6e71c9 |
We added support for the Islamic calendar. See https://stackblitz.com/edit/angular-qapxhn I set the locale to 'ar', 'en' is used as a fallback for the names of weekdays and months. I think there is still a RTL issue: Also abbreviations would be nice for transliterations of the Arabic names, see https://github.com/dhlab-basel/JDNConvertibleCalendar/blob/master/src/names.json Could you give me a hand here? |
btw: all the available calendars can also be used individually. In the date adapter, I still have to figure out a way to set the initial calendar correctly, see dhlab-basel/JDNConvertibleCalendarDateAdapter#9 |
(revisiting old feature requests) Closing this issue since I don't realistically ever see us prioritizing adding support for non-Gregorian calendars. With the current state of our backlog, it would be years before we would even consider this, and I don't foresee it ever getting near the top of the queue. |
I understand. Could you tell me anything about the priority of the precision task (year or month selection)? At the moment, the date and range pickers only allow for day selection. |
@tobiasschweizer it's something I'd like to explore eventually, but I don't see us dedicating any time to it in 2021 |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
I think making dateUtil.js injectable, would provide calendar support functionality for Hijri or Jalali or other international calendars in datepicker. Adding fromGregorian and toGregorian date functions to $mdDateLocale service may provide more abstract solution. These functions could be consequently used in dateUtil.js to provide localized date calculation. Currently $mdDateLocale just provide messages, formatters, and parsers for date internationalization but not date conversion.
I volunteer to produce dateUtil or $mdDateLocale for Hijri or Jalali. Please help me how.
The text was updated successfully, but these errors were encountered: