-
Notifications
You must be signed in to change notification settings - Fork 348
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
FluentCalendar behaves incorrect when setting Culture #1854
Comments
By the way, I can fix it and do a PR if required. |
As you understand the intricacies of such a calendar much better than we can, yes please supply a PR for this! Would be extra great is you can also add some unit tests for those cultures so we can monitor if we don't break stuff in the future (whichever culture we use). |
@vrassouli I agree with Vincent. It would be great to offer a PR that manages this culture too. |
I'd be glad to |
Sure but to include in the component. If I correctly understand, depending of the Culture, the display values must be adapted. Correct ? |
For example, there is a method named FirstDayOfMonth in FluentCalendar.razor.cs file, which returns the first day of month (and not using the culture) If you agree, I want to use these extensions and implement any missing ones. |
Yes. Sure. The best is to create or adapt the code and we will discuss in the PR with the concrete code. We trust in you. |
🐛 Bug Report
When setting
Culture
property of theFluentCalendar
, it does not behave correctly. Infact, after reviewing the source code, I noticed that it uses theCulture
property only for looking up the names (names of days and monthes) and not for the calulations.💻 Repro or Code Sample
<FluentCalendar Culture="_culture"></FluentCalendar>
@code { private CultureInfo _culture = new CultureInfo("fa-IR"); }
😯 Current Behavior
The provided code, produces the following output:
Date of today (int this output) is 04/14/2024 in Gregorian calendar, which equals to 01/26/1403 in Persian calendar.
As you see in the image:
🤔 Expected Behavior
💁 Possible Solution
The calculations should use the
Calendar
property of theCultureInfo
.For example the
GetMonthNameAndYear
method of theCalendarExtended
class is implemented as following:var result = $"{GetMonthName(Date)} {Date.Year}";
and should be changed to:
var result = $"{GetMonthName(Date)} {Culture.Calendar.GetYear(Date)}";
🔦 Context
For multi-language applications, to support better user experience, it's vital to make use of the features provided by the CultureInfo and the Calendar
🌍 Your Environment
Windows 11, Android, iOS
Edge, Chrome, Firefox
The text was updated successfully, but these errors were encountered: