Open AndroidDeveloperLB opened 6 years ago
Correct way to format the dates is as such:
private fun setupDateTimeInterpreter(shortDate: Boolean) {
val calendar = Calendar.getInstance()
calendar.set(Calendar.MINUTE, 0)
calendar.set(Calendar.SECOND, 0)
calendar.set(Calendar.MILLISECOND, 0)
val dateFormat = DateFormat.getTimeFormat(this@BaseActivity)
?: SimpleDateFormat("HH:mm", Locale.getDefault())
val format = SimpleDateFormat(" M/d", Locale.getDefault())
weekView.dateTimeInterpreter = object : DateTimeInterpreter {
...
override fun interpretDate(date: Calendar): String {
var weekday = DateUtils.getDayOfWeekString(date.get(Calendar.DAY_OF_WEEK), DateUtils.LENGTH_SHORT)
if (shortDate) {
val dayOfWeekString = DateUtils.getDayOfWeekString(date.get(Calendar.DAY_OF_WEEK), DateUtils.LENGTH_SHORTEST)
weekday = dayOfWeekString
}
return weekday + format.format(date.time)
}
}
}
But for the RTL issue, this is something else...
Suppose you take this when on English:
When I switch to Hebrew, I get this:
Almost all days here have the same letter, which is wrong because it's not how it should be on Hebrew. I think it's because the library truncates a longer text here, as you will see below.
Pressing "Today" will get it right:
However, only the days are ok. The order of them is incorrect, because Hebrew is an RTL language. This means that you are supposed to see the days from right to left.
See Google Calendar for example:
Sunday ("יום א" - first day) is on the right, then Monday, then Tuesday, then Wednesday, then Thursday (which is today - "יום ה" - the 5th day of the week) , then Friday, then Saturday ("שבת" - Sabbath, last day of the week) .
This is how it should have been.