You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ofbiz.apache.org by "Chatree Srichart (JIRA)" <ji...@apache.org> on 2012/10/01 12:53:07 UTC

[jira] [Created] (OFBIZ-5044) The loadDateDimension service is loading incorrect weekOfYear field.

Chatree Srichart created OFBIZ-5044:
---------------------------------------

             Summary: The loadDateDimension service is loading incorrect weekOfYear field.
                 Key: OFBIZ-5044
                 URL: https://issues.apache.org/jira/browse/OFBIZ-5044
             Project: OFBiz
          Issue Type: Bug
          Components: framework
    Affects Versions: SVN trunk
         Environment: Ubuntu 10.04
            Reporter: Chatree Srichart
             Fix For: SVN trunk


Hi all,

When I ran the loadDateDimension service with these dates:
- fromDate = "25 Dec 2010"
- thruDate = "05 Jan 2011"

I got:

- "25 Dec 2010" has the week of year as 52.
- "26 Dec 2010" has the week of year as 1.

Actually "26 Dec 2010" should has the week of year as 53.
I think the problem is "26 Dec 2010" is in the same week of "1 Jan 2011".

Regards,
Chatree Srichart

--
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

[jira] [Commented] (OFBIZ-5044) The loadDateDimension service is loading incorrect weekOfYear field.

Posted by "Paul Foxworthy (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/OFBIZ-5044?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13473697#comment-13473697 ] 

Paul Foxworthy commented on OFBIZ-5044:
---------------------------------------

Hi Chatree,

I think the problem is at https://fisheye6.atlassian.com/browse/ofbiz/trunk/framework/common/src/org/ofbiz/common/olap/CommonDimensionServices.java?hb=true#to89

dateValue.set("weekOfYear", new Long(calendar.get(Calendar.WEEK_OF_YEAR)));

The Java Calendar class will calculate the week of the year based on your locale. The first day of the week is Sunday in the US and Monday in Europe. The other factor is the minimal number of days you want in the first week of the year. See http://docs.oracle.com/javase/7/docs/api/java/util/Calendar.html for details.

Personally, I think Sunacle have got this horribly wrong, and should use the ISO week by default, see http://en.wikipedia.org/wiki/ISO_week_date for a discussion. I think that's the number you wanted to see.

I propose simply adding the lines

calendar.setFirstDayOfWeek( Calendar.MONDAY );
calendar.setMinimalDaysInFirstWeek( 4 );

before you request the week of the year.

If we must, we could add yet another configuration option to preserve the existing behaviour for those who want it. But locale-specific weeks only make sense for locale-specific data. The moment you have data from more than one place in the world, you need a worldwide standard. That standard is called ISO 8601. Let's just use it.

What do people think?
                
> The loadDateDimension service is loading incorrect weekOfYear field.
> --------------------------------------------------------------------
>
>                 Key: OFBIZ-5044
>                 URL: https://issues.apache.org/jira/browse/OFBIZ-5044
>             Project: OFBiz
>          Issue Type: Bug
>          Components: framework
>    Affects Versions: SVN trunk
>         Environment: Ubuntu 10.04
>            Reporter: Chatree Srichart
>              Labels: calendar, week_of_year
>             Fix For: SVN trunk
>
>   Original Estimate: 24h
>  Remaining Estimate: 24h
>
> Hi all,
> When I ran the loadDateDimension service with these dates:
> - fromDate = "25 Dec 2010"
> - thruDate = "05 Jan 2011"
> I got:
> - "25 Dec 2010" has the week of year as 52.
> - "26 Dec 2010" has the week of year as 1.
> Actually "26 Dec 2010" should has the week of year as 53.
> I think the problem is "26 Dec 2010" is in the same week of "1 Jan 2011".
> Regards,
> Chatree Srichart

--
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