Re: Converting Date-Time
Re: Converting Date-Time
- Subject: Re: Converting Date-Time
- From: "Adam Bell" <email@hidden>
- Date: Mon, 3 Apr 2006 20:47:06 -0300
Original script with corrections: forgot it is now DST, added 1 instead of subtracting. Now gives correct UTC for North American time zones for a date extracted as text with the zone info added (FWIW):
property zones : {"AST", "EST", "CST", "MST", "PST"}
set maildate to "Date: April 3, 2006 4:45 PM PST"
set dateZone to last word of maildate
set md to date maildate
-- get the zone offset
repeat with k from 1 to 5
if item k of zones = dateZone then
set adder to 3 + k
exit repeat
end if
end repeat
-- is it DST?
tell getDST(year of md)
if md > item 1 and md < item 2 then set adder to adder - 1
end tell
set UTC to (md + adder * hours as string) & " UTC"
--> "Monday, April 3, 2006 11:45:00 PM UTC"
-- a modified form of a script by Nigel Garvey
to getDST(the_year)
set yr to the_year
set the_year to (the_year + 8) mod 28 div 0.8
set DSTstart to 7 - ((the_year + 1) mod 7)
set DSTend to 31 - ((the_year + 5) mod 7)
set dss to date ("April " & DSTstart & ", " & yr & " 2:00 AM")
set dse to date ("October " & DSTend & ", " & yr & " 2:00 AM")
return {dss, dse}
end getDST
On 4/3/06, Matthew Smith <email@hidden> wrote:
on 04/04/2006 08:26, Luther Fuller at email@hidden wrote:
> OR ... If there is no function to convert to UTC ...
>
> Perhaps there is a way to determine if Daylight Savings Time is in
> currently in effect. I've looked in various .plist files, preferences
> &c., but found nothing.
Standard Additions includes:
time to GMT v : Return the difference between local time and GMT (Universal
Time)
time to GMT
→ integer : the difference between current time zone and Universal Time, in
seconds
--
Matthew Smith
_______________________________________________
Do not post admin requests to the list. They will be ignored.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden