[quote=127444:@John Fatte]An observation after reading this thread… this is a good example why some XOJO lurkers will opt to use something else.
Comments about someone’s suggestions should be positive and constructive rather than negative and demeaning.[/quote]
Changing development tool because one individual has bad manners is not logical. This forum has a great feature : click the name of the bad person, click ‘Ignore’,and all the posts from that particular individual will be suppressed from your view.
Pitiful name calling incident aside, I think this thread is on a contrary an example of why one would appreciate Xojo : such a thorough and high level exchange would not take place on many forums.
And unfortunately, there are forums out there where people are quite often an in larger number very nasty, like StackOverflow.com …
The number of days and number of weeks are most accurate, since the length of these units is fixed.
Now the big issue comes with the length of the month. You divide the difference in Totalseconds by 2592000, which is a 30 days month. It works fine to estimate the number of months apparently.
But the length of months is variable. On a non-leap year, the average length of the month is not 30 days. It is 30.416666666. Let us say 30.4167. For estimating the number of months it does not seem to pose problem, but to estimate the number of remaining days, which took quite a bit of this thread, it becomes an issue.
intDays-(intMonths*30.4167) produces 15.4163, which could be used with ceil to give 16 days, identical to Hamish and Tim’s method for 2013/2/20 - 2014/2/5. But this may require more testing with edge cases.
I like your approach for the number of weeks and months and the total number of days.
“Ask an accountant to calculate the same and I bet you he will proceed by calendar days. Let alone not to pay people on extra virtual days created by the method. Business usually considers months start on the first, not in the middle.”
Depends on the purpose. Each country has its own legal rules for how to compute months/days.
Interestingly, this summarizes the cultural differences. As J Andrew Lipscomb shows perfectly well, the 30 days month conduces to valid results in estimating the number of months, so it is probably not necessary to bother with a precise counting on days per month.
The main point this thread has shown is the very big difference between the US and Europe when counting days is concerned.
As you say, depends on the purpose. The accountant preparing payroll, or the bank calculating interest charges will do that on actual days.
Even within the US, there is disagreement about Daylight Savings Time… just ask Arizona
Also, another difference I noticed about dates when it comes to the US and Europe has to do with how dates are being displayed. Example:
US: MM/DD/YYYY
UK: DD/MM/YYYY
The only time I am aware in the US where we refer date as DD/MM is the 4th of July… Then you have the topic of what day starts a week day. Is it Sunday or Monday?
For the date, I prefer ours (French), DD is the lower, then MM middle, the YY biggest. More logic than MM DD YY .
Anyway, when I save file on my Mac with date in the name, I write MyFile YYYY-MM and eventually I write -DD .
YYYYMMDD makes the most sense for computer use
It naturally sorts in the correct order and its easy to parse
Oh and it was naturally also Y2K (and Y3K and Y4k up to Y10K compliant)
Yes - been there done that glad the accounting system used that form and only had to change 4 lines of code (after auditing about 80,000 lines)