Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Cyclic Calendar Dates
Forum Updated to NodeBB v4.3 + New Features

Cyclic Calendar Dates

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 1.4k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Q Offline
    Q Offline
    QtTommy
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0
    • JeroentjehomeJ Offline
      JeroentjehomeJ Offline
      Jeroentjehome
      wrote on last edited by
      #2

      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.

      Greetz, Jeroen

      1 Reply Last reply
      0
      • Q Offline
        Q Offline
        QtTommy
        wrote on last edited by
        #3

        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.

        1 Reply Last reply
        0
        • Q Offline
          Q Offline
          QtTommy
          wrote on last edited by
          #4

          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, ...@

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved