I’m creating a Windows MFC app in which I can ask the user to select a time difference from years right down to the second from a known time. For the sake of example, let’s assume a file’s creation date of 2020-11-01 16:00:00.
I could implement this as 6 spin controls to pick the difference, but perhaps this is not the best approach. Each is initialized to 0 and has positive and negative ranges for appropriate values—ie: 0 to 59 and -59 (total of 119 distinct values) for minutes. If I want to change the date & time to a future value like 2020-12-07 17:30:45, I could change each of the spin controls to add 1 month, 6 days, 1 hour, 30 minutes, and 45 seconds. Each part of the date is distinct, so I could add or subtract from each field the necessary amount to each field—ie: changing 2020-01-01 to 2019-12-31 would mean subtracting 1 year, adding 11 months, and adding 30 days.
What I’m not sure about is how most users will perceive time differences where any of those fields have a negative value. For example, if I now want to change 2020-12-01 16:00:00 to 2020-12-01 15:00:00 (ie: an hour fall back to account for DST change), it is easy enough to select -1 hours.
If I want to subtract a total of 1 hour, 23 minutes, and 45 seconds, should I be picking -1 hour, -23 minutes, -45 seconds or should I assume that as soon as a negative value is picked, the ranges for the following ones are changed to positive values only and assume they are to be concatenated to that negative value; that is to say, does picking -1 hour and 1 minute (positive) imply substracting 1:01:00 from a given time or would that be construed as a convenience factor of subtracting 1 hour but adding back 1 minute for a net effect of subtracting 59 minutes? It takes less effort to pick +1 from minutes rather than having to click 59 times down on minutes to -59 or (or click and hold once) to accelerate values.
How do I approach adding or subtracting 237 days without having to calculate a date difference depending on how many days are in each month and the added calculations of accounting for lear years depending on which date and time I start with?
I’m assuming MFC’s spin control has an “acceleration” value where, if I click and hold on 0, it will accelerate through my acceleration value of 10 to get to 10, 20, 30, etc (or 5 for 5, 10, 15, 20, 25, etc.). (or negative if I’m holding down oh the down arrow), but I haven’t coded that yet pending responses I get here.
Anyway, the bottom line is I want to adjust dates and times from a known value. I hope my explanation doesn’t add to the confusion, but I’ll leave it to my fellow software developers to let me know their approach to this. Thanks!