Skip to content

Add support for "ww" in date format (#12037) #12052

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

Merged
merged 1 commit into from
Jul 14, 2020
Merged

Add support for "ww" in date format (#12037) #12052

merged 1 commit into from
Jul 14, 2020

Conversation

Ansku
Copy link
Member

@Ansku Ansku commented Jul 9, 2020

Calculate number of the week in the year based on Date. Note, support for "ww" is missing from GWT DateTimeFormat and java.util.Calendar is not supported in GWT, hence DIY method is needed.

Fixes: #10603


This change is Reviewable

Calculate number of the week in the year based on Date. Note, support for "ww" is missing from GWT DateTimeFormat and java.util.Calendar is not supported in GWT, hence DIY method is needed.

Fixes: #10603
Copy link
Contributor

@edler-san edler-san left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 3 of 3 files at r1.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @Ansku)


client/src/main/java/com/vaadin/client/DateTimeService.java, line 45 at r1 (raw file):

Quoted 4 lines of code…
    private int[] yearDays = { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 
 304, 334 };
    private int[] leapYearDays = { 0, 31, 60, 91, 121, 152, 182, 213, 244, 274,  
305, 335};

Maybe just do a sum in countWeek?
Line break seem arbitrary.


client/src/main/java/com/vaadin/client/DateTimeService.java, line 416 at r1 (raw file):

Quoted 4 lines of code…
        boolean leap = false;
        if (((year % 4) == 0) && (((year % 100) != 0) || ((year % 400) == 0))) {
           leap = true;
        }

No need for the extra if.

boolean leap = ((year % 4) == 0) && (((year % 100) != 0) || ((year % 400) == 0)));


client/src/main/java/com/vaadin/client/DateTimeService.java, line 421 at r1 (raw file):

        int week;
        if (leap) {
            week = countWeek(leapYearDays, month, day, weekDay);

Maybe add being a leap year as a parameter?
I.e., week = countWeek(leapYearDays, month, day, weekDay, leap);

Copy link
Member Author

@Ansku Ansku left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @edler-san)


client/src/main/java/com/vaadin/client/DateTimeService.java, line 45 at r1 (raw file):

Previously, edler-san wrote…
    private int[] yearDays = { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 
 304, 334 };
    private int[] leapYearDays = { 0, 31, 60, 91, 121, 152, 182, 213, 244, 274,  
305, 335};

Maybe just do a sum in countWeek?
Line break seem arbitrary.

It matches the older maxDaysInMonth handling.
Page width is fixed in the project formatting rules.


client/src/main/java/com/vaadin/client/DateTimeService.java, line 416 at r1 (raw file):

Previously, edler-san wrote…
        boolean leap = false;
        if (((year % 4) == 0) && (((year % 100) != 0) || ((year % 400) == 0))) {
           leap = true;
        }

No need for the extra if.

boolean leap = ((year % 4) == 0) && (((year % 100) != 0) || ((year % 400) == 0)));

That would require a new pull request to the main branch, can't be done in a cherry-pick PR.


client/src/main/java/com/vaadin/client/DateTimeService.java, line 421 at r1 (raw file):

Previously, edler-san wrote…

Maybe add being a leap year as a parameter?
I.e., week = countWeek(leapYearDays, month, day, weekDay, leap);

Likewise for this one. (You'd also need to drop the first parameter.)

@Ansku Ansku merged commit 70fa998 into 8.11 Jul 14, 2020
@Ansku Ansku deleted the issue10603release branch July 14, 2020 09:46
@TatuLund TatuLund added this to the 8.12.0.alpha1 milestone Aug 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants