Re: Time anomaly
Re: Time anomaly
- Subject: Re: Time anomaly
- From: Brian Christmas <email@hidden>
- Date: Mon, 29 Oct 2012 10:23:19 +1100
On Oct 28, 2012, at 9:08 AM, Michelle Steiner wrote: On Oct 28, 2012, at 8:29 AM, Thomas Fischer wrote: I have to agree with Miguel, at least on my Snow Leopard system. Calculations with months (or years) don't work as they do with days and weeks:
set myDate to the current date set newDate to myDate + (371 * days) log newDate set newDate to myDate + (53 * weeks) log newDate set newDate to myDate + (12 * months) log newDate set newDate to myDate + (1 * year) log newDate
works for days and weeks, but not for months (actually already indicated by the colouring) and year (years is not a recognised term). So I suppose it's some sort of bug in the date calculation part of AppleScript.
"days" is a constant equal to 86400, which is the number of seconds in a day. "Day" is not used in this because it has another definition. (E.g., "day of (current date)")
Similarly "weeks" is a constant equal to 604800, the number of seconds in a week.
However, because the number of days in a month is not a constant, the number of seconds in a month can't be a constant, so "months" can't be a constant. Similarly because the number of days in a year isn't a constant, "year" or "years" can't be a constant.
It was suggested to me that aside from the obvious “Don’t do that” recommendation, the proper solution to these issues is to file a bug. It was speculatively considered that a probable solution would be to make AppleScript return a record of date/time elements, much as Cocoa does, which would allow you to modify those elements and then turn them back into a date, though I kind of like the idea of being able to just treat a date object’s properties as those elements, avoiding the whole “another data type” issue.
So, http://bugreport.apple.com if you are concerned enough to take action. If enough bugs get filed, a case can be made to fix the problem.
Jon
Thanks Jon.
Regards
Santa |
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden