dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #00957
Re: weeks calculation
>
> I think you can modify code to work correctly as long as it does not change start and end date generated in period table. DHIS weeks start at Sunday and end by Saturday, at least in Mozambique database, how did you come to Monday - Sunday?
>
> regards,
> murod
>
>From WeeklyPeriodType.java in dhis-api (excuse all the ^M's):
// ---------------------------------------------------------------------^M
// Generate weeks^M
// ---------------------------------------------------------------------^M
^M
cal.set( Calendar.WEEK_OF_YEAR, 1 );^M
cal.set( Calendar.DAY_OF_WEEK, Calendar.MONDAY );^M
^M
int firstWeek = cal.get( Calendar.WEEK_OF_YEAR );^M
^M
ArrayList<Period> weeks = new ArrayList<Period>();^M
^M
Date startDate = cal.getTime();^M
cal.add( Calendar.DAY_OF_YEAR, 6 );^M
weeks.add( new Period( this, startDate, cal.getTime() ) );^M
cal.add( Calendar.DAY_OF_YEAR, 1 );^M
^M
while ( cal.get( Calendar.WEEK_OF_YEAR ) != firstWeek )^M
{^M
startDate = cal.getTime();^M
cal.add( Calendar.DAY_OF_YEAR, 6 );^M
weeks.add( new Period( this, startDate, cal.getTime() ) );^M
cal.add( Calendar.DAY_OF_YEAR, 1 );^M
}^M
So you see - cal.set( Calendar.DAY_OF_WEEK, Calendar.MONDAY );. All
weekly periods start on a Monday. I've dumped these and verified.
Or is the period table being generated from somewhere else?
Regards
Bob
References