quote:
Originally posted by Jamibu
All i was wondering is if it was possible to introduce one more tag into the plugin, to display months. I am counting up from an event over 7 months ago, and I would prefer it to say 7 months, 4 days etc. than 218 days.
'Months' is a different kind of time unit than 'days', 'hours', 'minutes' and 'seconds'. Months (and years) do not have a fixed length, whereas days, hours, minutes and seconds do have a fixed length. An hour is always 60 minutes, a minute is always 60 seconds, etc
[*].... But a month is not always x days.
In context of counting down time, this is extremely important to make that difference. When dealing with the term 'months' in context of calculating elapsed
time (and thus not in context of
dates), it will always be 30 days, there is no logical way around it.
As CyBeRDuDe has said, you would think there are two ways of including such a tag:
1) Just divide the number of total days by 30, to give a number of elapsed months, and the rest would be elapsed days...
2) Calculate each month ahead, including 1 day in february when leap year, etc...
Now, method 2 is not so accurate as you might think. In fact it will be way more off and inconsistant in many circumstances. This is because you are mixing two contextual things together: dates and elapsed time. Those two can't be logically mixed. eg:
Consider two datetimes (leaving the hours, minutes and seconds away for the purpose of simplification): '28 februari 2005' and '28 march 2005'. How many months are there between the two dates? Following the logic of point 2, you would say, precisly 1 month, and I would agree with you...
Same with '17 September' -> '17 October' = 1 month
Same with '5 June' -> '5 July' = 1 month
But consider another starting datetime: '31 march 2005'
When will there be 1 month elapsed? 30 april? 1 may?
If you say 30 april, then what about if the start date was 30 march?
If you say 1 may, wouldn't that make the start date 1 april?
If you say you had dinner 1 month ago, and the current date is:
29 march, when did you had the dinner? 28 februari? 1 march?
30 march, when did you had the dinner? 28 februari? 1 march? 2 march?
31 march, when did you had the dinner? 28 februari? 1 march? 2 march? 3 march?
Or: It is januari 29th, and you will have dinner in 1 month. does that mean februari 28th? march 1st? What about having dinner in 1 month and 2 days? What would that be?
Or: It is march 29th, and you had dinner 1 month and 1 day ago. When did you had the dinner?
Or: It is march 29th, and you had dinner 1 month and 2 days ago. When did you had the dinner?
As you can see there is no logic in all this, and that is why, in context of time differences, a month is always considered 30 days.
Unless you only consider the month number and not days, hours, etc. eg: now it is march, one month ago it was februari (even if you say this on march 31st).
That is also why, when you ask to calculate the difference in units of months, any API function and other native function of a programming language wich deals with datetime differences will only consider the month and will disregard any other time unit. Thus you'll get: februari 1st - januari 31st = 1 month, although only 1 day has ellapsed. Or if other time units can't be disregarded (as in the countdown plugins) it will always take 30 days as a 'month'...
(The same with year calculations btw)
-----
[*]Although a day will not always be 60*60*24 seconds! This is extremely rare though.
But as a matter of fact, december 31st 2005 will actually be 1 second longer if you live in the GMT or a GMT- timezone!! If you live in a GMT+ timezone januari 1st will be 1 second longer. This is what is called a leap second.