← Back to team overview

dhis2-devs team mailing list archive

Re: weeks calculation

 

Well


Bob Jolliffe wrote:
Hi cave persons

2009/5/11 Murodullo Latifov <murodlatifov@xxxxxxxxx>:

How dhis2 calculate the weeks? The first week of a year for example.

Weekly periods are calculated based on their start date. If start date of the given week is on the previous year, end date of that period is used. Also Saturday is used as first day of the week.


It seem this business of Saturdays is a red herring and is not true.
Weekly periods are defined by a start date being a Monday and an end
date being a Sunday (though this doesn't seem to be enforced anywhere
- it probably should be).  We can see this in the list of periods
which are calculated in generatePeriods in WeeklyPeriodType.java.  The
list are all all Monday-Sunday periods.

It is however a bit buggy.  What I can confirm from generating loads
of period lists from various starting dates is
1.  DHIS (using the java default) does indeed have an ISO8601
interpretation of week number.  That is the first week of any given
year is a the first week with a Thursday in it.  It is good we stick
with this.  Makes it easy to answer the question "how does DHIS2
handle week numbers?".
2.  Perhaps somebody who initially wrote this code seemed not quite to
appreciate how this works, which means, for example, that when we
generate the period list for the week of 29-12-2009 to 03-01-2010 we
end up with a list starting with week 1 of 2010, which doesn't
actually include the given week.  The same thing happens in the end of
2005.

I don't know if this is at the root of Orvalho's problem (I haven't
yet seen his data), but it is clearly important when moving weekly
data from one system to another.  Meanwhile I can fix the
generatePeriods method so that it will always generate the correct
list of periods for any given period.  Before I do so please confirm
that it will not break any existing data, reports or what have you.
The implication being that  generatePeriods called on the week of
29-12-2009 to 03-01-2010 will generate the list of weeks for 2009, not
2010.  And more obviously, the week of 26-12-2005 to 1-01-2006
generates the list of weeks for 2005, not 2006.

Yes this a problem for us. Because we expect to use correctly DHIS [reporting tools for now] and we need to map exactly the periods from the actual system to DHIS.

But meanwhile there is a another problem with a lot of empty data on that system. Mine foucus has been on that and I forgot for a while these dateweeks troubles.

Anyway, can you corect the DHIS2 code please to calculate weekdates? If it is buggy.

Cheers
Bob

_______________________________________________
Mailing list: https://launchpad.net/~dhis2-devs
Post to     : dhis2-devs@xxxxxxxxxxxxxxxxxxx
Unsubscribe : https://launchpad.net/~dhis2-devs
More help   : https://help.launchpad.net/ListHelp

Regards
Caveman




Follow ups

References