← Back to team overview

dhis2-devs team mailing list archive

Re: weeks calculation

 

Hi Orvalho

2009/5/11 Orvalho Joaquim Augusto <orvaquim@xxxxxxxxx>:
> Well this comment is interesting.
>
> And the question raises from my needs here. I am moving data from a not
> dhis2 system to dhis2. And we must do it weekly because dhis2 is not yet
> adopted.
>
> I noticed that I had weeks changed on dhis2.

Do you have some examples?  i.e. ones which show that week 1 is
indicated as something specific for a particular year which is
different to the DHIS2 way.  Then maybe we can start thinking about
how DHIS2 should best handle.  Is your data coming from Excel?

Regards
Bob

PS. I see mysql makes use of a mode argument
http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_week
I guess ISO8601 mode would be mode 3 under this scheme.

PPS.  Excel does not have a weeknum function built in.  There is an
analysis toolpack plugin which implements something non-standard -
somteimes described as the US norm - the first week (like other weeks)
ends on Sunday.  It can be any number of days long from 1 to 7.

PPPS.  David Wheeler has done some excellent work on the OpenFormula
SubCommittee of the ODF OASIS TC on figuring out the differences
between all these.  It looks like ODF will eventually adopt two
functions WEEKNUM (which implements the incorrect Excel algorithm) and
ISO_WEEKNUM which implements the correct algorithm.



> And now to adjust to dhis2 I need to know how dhis2 does. And Bob raises
> this. What I do? I use the algorithm from that java Class?
>
> Caveman
>
> Bob Jolliffe wrote:
>>
>> Hi
>>
>> 2009/5/11 Murodullo Latifov <murodlatifov@xxxxxxxxx>:
>>>
>>> Hi Caveman,
>>>
>>>
>>>
>>> ----- Original Message ----
>>> From: Orvalho Joaquim Augusto <orvaquim@xxxxxxxxx>
>>> To: dhis2-devs <dhis2-devs@xxxxxxxxxxxxxxxxxxx>
>>> Sent: Monday, May 11, 2009 2:57:42 AM
>>> Subject: [Dhis2-devs] weeks calculation
>>>
>>> I could not find on dhis2 docs so I am asking:
>>>
>>> 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.
>>
>> The code is here:
>> ./dhis-api/src/main/java/org/hisp/dhis/period/WeeklyPeriodType.java
>>
>> I find it a bit confusing.  It seems that we try to define a week as
>> Saturday to Friday, and then say that as long as the endDate is in a
>> different year to the startDate then we are in week 1.  So week 1 is
>> the first week in the year with a Friday in it?  This doesn't sound
>> right.  Also according to documentation on top of class, a weekly
>> period must have a startDate on a Monday and endDate on a Sunday.
>>
>> But week numbers according to ISO8601 are equivalent to the number of
>> Thursdays - ie. first week in the year with a Thursday is week 1.
>> This is the way that, for example the javascript in the calendar.js
>> would calculate it.  And presumably any sql week function we might
>> use.  Also weeks would start on Monday (which agrees with our class
>> documentation).
>>
>> So for the week of 29/12/2008 to 04/01/2009, by our calculation that
>> would be week 1 of 2009.  And it would be week 1 by ISO 8601.
>>
>> But for the week of 28/12/2009 to 3/01/2010 which is coming up, our
>> calculation would have this as week 1 of 2010, whereas ISO8601 would
>> have it as week 52 or 53 of 2010.  Week 1 would be the week of
>> 04/01/2010.
>>
>> As I say - its a bit confusing.
>>
>> Though perhaps in the end the actual week number doesn't matter.  What
>> might matter most is the convention we consistently adopt and
>> document.  Though it would be nice if our conception of week 1
>> coincided with the ISO8601 conception.  But not so nice as to break
>> all the annual reports ... Do we ever exchange a week number with
>> another system?  Do we need to be able to define this more flexibly to
>> accomodate different national reporting requirements which might
>> interpret the first week of the year differently?  I haven't even
>> begun to think of this in terms of localised calendar systems :-)
>>
>> Regards
>> Bob
>>
>>> Thank you
>>> Caveman
>>>
>>>
>>>
>>> _______________________________________________
>>> 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
>>>
>>>
>>>
>>>
>>>
>>> _______________________________________________
>>> 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
>>>
>>
>
>



Follow ups

References