Converting to Arabic Language giving wrong Days in Calendar
See original GitHub issueI am using Example # 2 from Sample, in English language it is giving me correct Days of the Calendar like 1st Jan 2021 is Friday, but if I am changing device Language to Arabic, it is giving me wrong Dates like: 1st Jan 2021 on Saturday.
I am using daysOfWeekFromLocale()
from Ext for week days and changing my Preferred start of week as Sunday also,
fun daysOfWeekFromLocale(): Array<DayOfWeek> {
val firstDayOfWeek = WeekFields.of(Locale.getDefault()).firstDayOfWeek
var daysOfWeek = DayOfWeek.values()
// Order `daysOfWeek` array so that firstDayOfWeek is at index 0.
// Only necessary if firstDayOfWeek != DayOfWeek.MONDAY which has ordinal 0.
if (firstDayOfWeek != DayOfWeek.SUNDAY) {
val rhs = daysOfWeek.sliceArray(firstDayOfWeek.ordinal..daysOfWeek.indices.last)
val lhs = daysOfWeek.sliceArray(0 until firstDayOfWeek.ordinal)
daysOfWeek = rhs + lhs
}
return daysOfWeek
}
For reference you can see screenshots from English Language and also from Arabic. Both are from Sample Code Example # 2.
ENGLISH ONE (1st Jan 2021 is Friday)
ARABIC ONE (1st Jan 2021 on Saturday)
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
c# - ToLongDateString() showing wrong date in Arabic
When you work with ar-AE culture - Arabic language, United Arab Emirates you represent given DateTime as a string according to this culture....
Read more >Error in converting Hijri Date to Gregorian Date
The conversion documentation shows that the input for Hijri dates should be in the format of "dd/mm/yyyy". Is 30/02/1434 a valid date?
Read more >Excel Dates Displayed in Different Languages
Excel Dates Displayed in Different Languages using the TEXT Function to easily convert the language for day and month.
Read more >Change your language setting - Google Calendar Help
Open Google Calendar. Settings. In the "Language" section, choose the language you want to use from the drop-down menu. Changes are automatically saved....
Read more >Change language in date (year, month, day)
Hi,. I solved this issue by going to "Date Settings" in Windows and changing the regional format to English. Restart Power BI and...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Really thank you @kizitonwose . This solution works like a charm. I also did same.
To ensure that the calendar always starts from Sunday, you need to do two things:
When setting up the headers, do NOT use this:
~
val daysOfWeek = daysOfWeekFromLocale()
~Use this instead:
Then setup the calendarView like this:
calendarView.setup(startMonth, endMonth, DayOfWeek.SUNDAY)