For a series of calculations I need to do, I need to convert a date and time to the number of days since 1/1/00 UTC. Basically, I am converting date/time into seconds and doing some simple math, but a person may need to specify a time zone other than the one they are currently in.
My current solution is to have time zone offset as an option in the equation, and extract the local offset through the internet date. This solution seems rather inelegant, and was wondering if there were a cleaner way of converting the date/time into seconds assuming a different time zone, or if there were at least a simpler way of getting the local time zone.
Here is my current function:
function epochDate pDate pTZ
convert pDate to seconds
if pTZ is not empty then
local tLocalTime, tLocalTZ
put the internet date into tLocalTime
set itemdel to space
put item -1 of tLocalTime into tLocalTZ
put char 1 to -3 of tLocalTZ into tLocalTZ
subtract ((pTZ-tLocalTZ )*3600) from pDate
divide pDate by 86400 --converts seconds into days
subtract 10956 from pDate
Greg (pink) Miller
mad, pink and dangerous to code