Cyclic Calendar Dates
-
At the moment I have the following problem: I have to implement a calendar function which allows the user to store cyclic dates (every week, every second week, every third week, every fourth week) and let him choose the first execution (this week, next week, in two weeks, in 3 weeks). For storing this information I have only two integer variables( iPeriod and iFirstExecution). For example I have a cycle of 3 weeks and the first execution is next week. That means that the cycle of 3 weeks continues from the week of the first start. How can store and find out if this date should be shown in the current calendarweek without storing the calenderweek in which the date was created seperately.
-
Hi,
Why do you only have two integer values to store information? Might the use of the QDateTime class be more appropriate? There are many easy functions that are able to handle the 'shift' and 'add' functions for dates even taken into account the months, leap years etc!
I would suggest to implement a class with settings that control every date input. -
Hi Jeroen
Thanks for your answer. The background of the project is that we have an old microcontroller based control without a calendar functionality which should be modernized in 2 steps. In the first step we are developing a new human machine interface which is built on an arm 9 processor in combination of a modern touchscreen display. we are running an embedded linux operating system on it. But in this intermediate step we are communicating with the old control via CANBus therefore the datastructure have to fit to the existing datastructure of the old control. That means for me that all calculations should work in the same way like in the old control. In the next step we transfer and reimplement the functionality of the old control to our new arm - processorcontrol.
-
I know that it is possible to store the information in this two variables because the developer of the old control realized it. But he isn't working no longer in this company and therefore I cannot ask him how it works. If we have a cycle of 3 weeks and we start in two weeks than he is not storing the value '2' in the Variable iFirstExecution. I think the calculation should word like this but at the moment I'm not absolutely sure.
@iValueToStore =CurrentCalendarWeek%iPeriod+iFirstExecution;
if(iFirstExecution>=iPeriod){iFirstExecution -= iPeriod;
}
//iFirstExecution -> 1=thisWeek,2=nextWeek,...
//Period -> 1 = everyWeek, 2=everySecondWeek, ...@