Re: Current date in standard additions dictionary
Re: Current date in standard additions dictionary
- Subject: Re: Current date in standard additions dictionary
- From: Nigel Garvey <email@hidden>
- Date: Mon, 4 Jun 2001 13:28:40 +0100
Victor Yee wrote on Sun, 3 Jun 2001 17:03:58 -0400:
>
On Sun, 3 Jun 2001 12:07:57 EDT, email@hidden wrote,
>
>
> I want to get the time only from current date command, without the
>
seconds
>
> added. Does anybody know if/how I can do this? Thanks.
>
>
I'll chip in too :-)
>
>
on get12HrTime(thisDate)
>
set t to thisDate's time
>
set h to (t div 3600)
>
if h > 12 then
>
set {h, x} to {h - 12, "pm"}
[...]
This is probably the most convenient way to return a 12-hour string
without relying on the host computer's Date & Time settings. In the UK,
however, 12-hour time counts the period 0:00:00 to 0:59:59 as
12-something am and the period 12:00:00 to 12:59:19 as 12-something pm.
For this, the handler would have to be modified something like so:
on get12HrTime(thisDate)
set t to thisDate's time
set h to (t div hours)
if h >= 12 then
set x to "pm"
else
set x to "am"
end if
set h to h mod 12
if h = 0 then set h to 12
return ("" & h & ":" & text -2 thru -1 of ("0" & (t mod hours) div
minutes) & x)
end get12HrTime
get12HrTime(current date)
NG