[jira] [Comment Edited] (OFBIZ-5196) TemporalExpressions$DayOfWeekRange: copy+paste logic errors

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[jira] [Comment Edited] (OFBIZ-5196) TemporalExpressions$DayOfWeekRange: copy+paste logic errors

Nicolas Malin (Jira)

    [ https://issues.apache.org/jira/browse/OFBIZ-5196?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13658702#comment-13658702 ]

Russell Morrisey edited comment on OFBIZ-5196 at 5/15/13 7:44 PM:
------------------------------------------------------------------

The following logic changes are needed.

first(...) method:
        Change to adding days, instead of months

includesDate(...) method:

        if (start < end) {
            return dow >= start && dow <= end;
        }
        else if (start > end) {
            return dow >= start || dow <= end;
        }
        else { //start == end
            return false;
        }

isSubstitutionCandidate(...) method:
        Subtract days, instead of months (I'm assuming; didn't test this).

next(...) method:
        In two places, change to adding days instead of months.
        Change the last "if" statement to determine the 'day of year' instead of 'month of year'.
        Change 'monthBumped' to 'dayBumped'.




               
      was (Author: rmorrise):
    The following logic changes are needed.

first(...) method:
        Change to adding days, instead of months

includesDate(...) method:

        if (start < end) {
            return dow >= start && dow <= end;
        }
        else if (start > end) {
            return dow >= start || dow <= end;
        }
        else { //start == end
            return false;
        }

next(...) method:
        In two places, change to adding days instead of months.
        Change the last "if" statement to determine the 'day of year' instead of 'month of year'.
        Change 'monthBumped' to 'dayBumped'.





                 

> TemporalExpressions$DayOfWeekRange: copy+paste logic errors
> -----------------------------------------------------------
>
>                 Key: OFBIZ-5196
>                 URL: https://issues.apache.org/jira/browse/OFBIZ-5196
>             Project: OFBiz
>          Issue Type: Bug
>    Affects Versions: SVN trunk
>            Reporter: Russell Morrisey
>
> TemporalExpressions$DayOfWeekRange contains incorrect code which appears to be copied-and-pasted from DayOfMonthRange. It adds months to the calendar object, where weeks or days should be used.
> Example (TemporalExpressions.java, 412-419):
>         @Override
>         public Calendar first(Calendar cal) {
>             Calendar first = (Calendar) cal.clone();
>             while (!includesDate(first)) {
>                 first.add(Calendar.DAY_OF_MONTH, 1); //This is wrong
>             }
>             return first;
>         }
> This problem appears in several places throughout this inner class.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira