Re: class reference "date" problems
Re: class reference "date" problems
- Subject: Re: class reference "date" problems
- From: Nigel Garvey <email@hidden>
- Date: Thu, 07 May 2015 21:16:24 +0100
Shane Stanley wrote on Thu, 07 May 2015 09:50:53 +1000:
>On 24 Apr 2015, at 7:58 am, has <email@hidden> wrote:
>>
>> One other thing: if you want to construct AppleScript date objects
>>reliably in a non-locale-dependent way, use the following handler:
>>
>> on makeDate(y, m, d, hr, min, sec)
>> set newDate to current date
>> tell newDate to set {its year, its month, its day, its time} to
{y, m,
>>d, hr * hours + min * minutes + sec}
>> return newDate
>> end makeDate
>
>Just don't try that with a date BC.
And even with AD dates, the day should additionally be set to a value
below 29 before the month's set in order to avoid overflow into the
following month when (current date)'s day number is higher than the
number of days in the target month:
set newDate to current date
tell newDate to set {its year, its day, its month, its day, its time} to {y, 1, m, d, hr * hours + min * minutes + sec}
Alternatively, the month can be set twice, any overflow from the first
setting resulting in a low day number which won't affect the second
setting:
set newDate to current date
tell newDate to set {its year, its month, its month, its day, its time} to {y, m, m, d, hr * hours + min * minutes + sec}
NG
_______________________________________________
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