dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #00961
Re: weeks calculation
Hi Saptarshi
2009/5/12 Saptarshi Purkayastha <sunbiz@xxxxxxxxx>:
> Its bad to re-invent the wheel, but I think we just keep doing that all the
> time. The Java API has all these things built-in, but we seem to have our
> own conventions for everything...
> The Calender class does all the good work with enough locale specific
> things...
>
> http://java.sun.com/javase/6/docs/api/java/util/Calendar.html#getFirstDayOfWeek()
Sorry, but its not quite as simple as that. The Calendar class lets
you specify important things like the setFirstDayOfWeek and
setMinimalDaysInFirstWeek, but it doesn't decide on those values for
you. And the WeeklyPeriodType is of course using the Calendar class.
When generating weekly periods for a year it has setFirstDayOfWeek to
Monday. We don't specify MinimalDaysInFirstWeek so I checked - we get
4 as a default, which is fine. In other words DHIS2 generates ISO8601
compliant week numbers (using the calendar class) which is excellent.
There are only three problems:
1. there is a small bug in the generator which I would like to fix
2. we don't validate when we construct weekly periods. For example
we construct a weekly period with three parameters - type (weekly),
start date and end date. When we construct we should ensure that
startdate is a Monday and that enddate is indeed 6 days apart from
startdate. Otherwise it is possible, through the API, to construct
invalid weekly periods. This probably shouldn't be. (in fact having
both start and enddate is strictly redundant - but I can see how it is
there in support of generality).
3. its not clear how to deal with importing weekly data from a system
which does not use ISO8601 week numbering. This would probably
include a number of VB/Excel/Access type applications. Either (i) we
must be completely agnostic towards the week numbering scheme and
accept anything with a start and end date 6 days apart as a week (or
even short weeks as per US convention) or (ii) we need to have an
approved process of grafting periods into (and perhaps out of) the
ISO8601 scheme. The first option is always a good interoperability
principle but I'm not sure we have the algorithms elsewhere, in the
reporting modules for example, to support it. The second option is a
bit gruff, and I'm not sure how it squares with Vietnamese and
Ethiopian dates for example. (What's a Vietnamese week?) But its
straightforward to implement.
Agreed we should use the Calendar class for all this. But how
exactly? Does anybody else have some experience of dealing with the
vagaries of exchanging weekly data? How does DHIS1.4 understand it?
Do weeks run from Monday to Sunday or Sunday to Saturday? Or
Wednesday to Tuesday with the first week in the year being the first
Wednesday after Easter :-)
Regards
Bob
> ---
> Regards,
> Saptarshi PURKAYASTHA
> Director R & D, HISP India
> Health Information Systems Programme
>
> My Tech Blog: http://sunnytalkstech.blogspot.com
> You Live by CHOICE, Not by CHANCE
>
>
> 2009/5/12 Murodullo Latifov <murodlatifov@xxxxxxxxx>
>>
>> Hi Caveman,
>>
>>
>>
>> ----- Original Message ----
>> From: Orvalho Joaquim Augusto <orvaquim@xxxxxxxxx>
>> To: Bob Jolliffe <bobjolliffe@xxxxxxxxx>
>> Cc: dhis2-devs <dhis2-devs@xxxxxxxxxxxxxxxxxxx>
>> Sent: Tuesday, May 12, 2009 2:08:43 PM
>> Subject: Re: [Dhis2-devs] weeks calculation
>>
>> Well
>>
>> 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.
>>
>> Regards
>> Caveman
>>
>> Are current periods in Mozambican database generated by DHIS or they are
>> also imported from elsewhere?
>>
>> murod
>> _______________________________________________
>> 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
>
>
> _______________________________________________
> 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