Hans,
This code will break in France. It would be better to increment a calendar until the week changes, then subtract a day. -Adrian [hidden email] wrote: > Author: hansbak > Date: Fri Jul 31 06:51:26 2009 > New Revision: 799525 > > URL: http://svn.apache.org/viewvc?rev=799525&view=rev > Log: > fill also the last week of the monthview > > Modified: > ofbiz/trunk/applications/workeffort/webapp/workeffort/WEB-INF/actions/calendar/Month.groovy > > Modified: ofbiz/trunk/applications/workeffort/webapp/workeffort/WEB-INF/actions/calendar/Month.groovy > URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/workeffort/webapp/workeffort/WEB-INF/actions/calendar/Month.groovy?rev=799525&r1=799524&r2=799525&view=diff > ============================================================================== > --- ofbiz/trunk/applications/workeffort/webapp/workeffort/WEB-INF/actions/calendar/Month.groovy (original) > +++ ofbiz/trunk/applications/workeffort/webapp/workeffort/WEB-INF/actions/calendar/Month.groovy Fri Jul 31 06:51:26 2009 > @@ -63,6 +63,11 @@ > firstWeekNum = tempCal.get(Calendar.WEEK_OF_YEAR); > context.put("firstWeekNum", new Integer(firstWeekNum)); > > +// also get days until the end of the week at the end of the month > +lastWeekCal = UtilDateTime.toCalendar(UtilDateTime.addDaysToTimestamp(start, numDays - prevMonthDays), timeZone, locale); > +followingMonthDays = 7 + lastWeekCal.getFirstDayOfWeek() - lastWeekCal.get(Calendar.DAY_OF_WEEK); > +if (followingMonthDays < 7) numDays += followingMonthDays; > + > serviceCtx = UtilMisc.toMap("userLogin", userLogin, "start", getFrom,"numPeriods", new Integer(numDays), "periodType", new Integer(Calendar.DATE)); > serviceCtx.putAll(UtilMisc.toMap("partyId", partyId, "facilityId", facilityId, "fixedAssetId", fixedAssetId, "workEffortTypeId", workEffortTypeId, "locale", locale, "timeZone", timeZone)); > if (entityExprList) { > > > |
Adrian, please feel free to correct it in the trunk as long as the last
row of the month is filled? I do not really understand what you mean. Regards, Hans On Fri, 2009-07-31 at 07:53 -0700, Adrian Crum wrote: > Hans, > > This code will break in France. It would be better to increment a > calendar until the week changes, then subtract a day. > > -Adrian > > [hidden email] wrote: > > Author: hansbak > > Date: Fri Jul 31 06:51:26 2009 > > New Revision: 799525 > > > > URL: http://svn.apache.org/viewvc?rev=799525&view=rev > > Log: > > fill also the last week of the monthview > > > > Modified: > > ofbiz/trunk/applications/workeffort/webapp/workeffort/WEB-INF/actions/calendar/Month.groovy > > > > Modified: ofbiz/trunk/applications/workeffort/webapp/workeffort/WEB-INF/actions/calendar/Month.groovy > > URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/workeffort/webapp/workeffort/WEB-INF/actions/calendar/Month.groovy?rev=799525&r1=799524&r2=799525&view=diff > > ============================================================================== > > --- ofbiz/trunk/applications/workeffort/webapp/workeffort/WEB-INF/actions/calendar/Month.groovy (original) > > +++ ofbiz/trunk/applications/workeffort/webapp/workeffort/WEB-INF/actions/calendar/Month.groovy Fri Jul 31 06:51:26 2009 > > @@ -63,6 +63,11 @@ > > firstWeekNum = tempCal.get(Calendar.WEEK_OF_YEAR); > > context.put("firstWeekNum", new Integer(firstWeekNum)); > > > > +// also get days until the end of the week at the end of the month > > +lastWeekCal = UtilDateTime.toCalendar(UtilDateTime.addDaysToTimestamp(start, numDays - prevMonthDays), timeZone, locale); > > +followingMonthDays = 7 + lastWeekCal.getFirstDayOfWeek() - lastWeekCal.get(Calendar.DAY_OF_WEEK); > > +if (followingMonthDays < 7) numDays += followingMonthDays; > > + > > serviceCtx = UtilMisc.toMap("userLogin", userLogin, "start", getFrom,"numPeriods", new Integer(numDays), "periodType", new Integer(Calendar.DATE)); > > serviceCtx.putAll(UtilMisc.toMap("partyId", partyId, "facilityId", facilityId, "fixedAssetId", fixedAssetId, "workEffortTypeId", workEffortTypeId, "locale", locale, "timeZone", timeZone)); > > if (entityExprList) { > > > > > > Antwebsystems.com: Quality OFBiz services for competitive rates |
Hans,
Here is the problem: in the line of code followingMonthDays = 7 + lastWeekCal.getFirstDayOfWeek() - lastWeekCal.get(Calendar.DAY_OF_WEEK); you are assuming the week starts with day one and ends with day seven. In some countries (France, for instance) the week starts on Monday (day two) and ends on Sunday (day one). -Adrian Hans Bakker wrote: > Adrian, please feel free to correct it in the trunk as long as the last > row of the month is filled? I do not really understand what you mean. > > Regards, > Hans > > On Fri, 2009-07-31 at 07:53 -0700, Adrian Crum wrote: >> Hans, >> >> This code will break in France. It would be better to increment a >> calendar until the week changes, then subtract a day. >> >> -Adrian >> >> [hidden email] wrote: >>> Author: hansbak >>> Date: Fri Jul 31 06:51:26 2009 >>> New Revision: 799525 >>> >>> URL: http://svn.apache.org/viewvc?rev=799525&view=rev >>> Log: >>> fill also the last week of the monthview >>> >>> Modified: >>> ofbiz/trunk/applications/workeffort/webapp/workeffort/WEB-INF/actions/calendar/Month.groovy >>> >>> Modified: ofbiz/trunk/applications/workeffort/webapp/workeffort/WEB-INF/actions/calendar/Month.groovy >>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/workeffort/webapp/workeffort/WEB-INF/actions/calendar/Month.groovy?rev=799525&r1=799524&r2=799525&view=diff >>> ============================================================================== >>> --- ofbiz/trunk/applications/workeffort/webapp/workeffort/WEB-INF/actions/calendar/Month.groovy (original) >>> +++ ofbiz/trunk/applications/workeffort/webapp/workeffort/WEB-INF/actions/calendar/Month.groovy Fri Jul 31 06:51:26 2009 >>> @@ -63,6 +63,11 @@ >>> firstWeekNum = tempCal.get(Calendar.WEEK_OF_YEAR); >>> context.put("firstWeekNum", new Integer(firstWeekNum)); >>> >>> +// also get days until the end of the week at the end of the month >>> +lastWeekCal = UtilDateTime.toCalendar(UtilDateTime.addDaysToTimestamp(start, numDays - prevMonthDays), timeZone, locale); >>> +followingMonthDays = 7 + lastWeekCal.getFirstDayOfWeek() - lastWeekCal.get(Calendar.DAY_OF_WEEK); >>> +if (followingMonthDays < 7) numDays += followingMonthDays; >>> + >>> serviceCtx = UtilMisc.toMap("userLogin", userLogin, "start", getFrom,"numPeriods", new Integer(numDays), "periodType", new Integer(Calendar.DATE)); >>> serviceCtx.putAll(UtilMisc.toMap("partyId", partyId, "facilityId", facilityId, "fixedAssetId", fixedAssetId, "workEffortTypeId", workEffortTypeId, "locale", locale, "timeZone", timeZone)); >>> if (entityExprList) { >>> >>> >>> |
Free forum by Nabble | Edit this page |