-
Notifications
You must be signed in to change notification settings - Fork 79
fix(date-picker): display correct day for first day of month in ar
locale
#6309
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
Changes from 2 commits
7eeaf1c
f259799
0fa7d0a
424a99c
31402ec
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -277,10 +277,16 @@ export class DatePickerMonth { | |
const date = lastDate.getDate(); | ||
const day = lastDate.getDay(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nitpick: For consistency, should this be |
||
const days = []; | ||
if (day - 6 === startOfWeek) { | ||
|
||
if (day === (startOfWeek + 6) % 7) { | ||
return days; | ||
} | ||
for (let i = lastDate.getDay() - startOfWeek; i >= 0; i--) { | ||
|
||
if (day === startOfWeek) { | ||
return [date]; | ||
} | ||
|
||
for (let i = (7 + day - startOfWeek) % 7; i >= 0; i--) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My mental math is pretty bad so don't hold me to this, but it seems like these changes could effect more than just a single locale. I was expecting some kind of change in the nls data - don't we have a The linked PR seems unrelated so I'm not sure what the exact issue is, can you link the correct one? Nitpick: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I am sure we are on the same boat 😆 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The linked PR is not the root cause, the earlier logic of determining which dates from previous months to display is what causing the issue when the weekStart is set to Irrespective of the weekStart inside the Other issue ( the root cause) is that we can't directly use difference in indexes to determine which dates from previous month should be rendered in current because if the weekStart is set to Saturday (6) and the last day of previous month is Monday(1) , the difference is 5 which means we need to display last 5days of previous month. But in reality, we just need to need to display Saturday, Sunday, Monday from previous month dates. To remove the circular number system ( there might be right term for this , but this is how i imagined in my mind lol) , i added I tried multiple combinations and looked at code piece for I agree complex logic like these are hard to review and maintain but it is unavoidable in this case . There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you at least create a const for Creating one for |
||
days.push(date - i); | ||
} | ||
return days; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -203,6 +203,17 @@ export const britishLang_TestOnly = (): string => | |
)} | ||
</div>`; | ||
|
||
export const arabicLang_TestOnly = (): string => | ||
html`<div style="width: 400px"> | ||
${create( | ||
"calcite-date-picker", | ||
createAttributes({ exceptions: ["lang", "value"] }).concat([ | ||
{ name: "lang", value: "ar" }, | ||
{ name: "value", value: "2022-08-11" } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe the value can be added to the existing |
||
]) | ||
)} | ||
</div>`; | ||
|
||
export const chineseLang_TestOnly = (): string => | ||
html`<div style="width: 400px"> | ||
${create( | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unrelated nitpick: this method is not following our casing convention and should be
getPrevMonthDays
(notgetPrevMonthdays
).