Title: Re: received message timing (It's about time....)
A quick search finds that most time zones are some multiple of hours off from Greenwich mean time, but there are a some time zones that are are mid-way (30 minutes) between others.  See, for example,
http://www.timeanddate.com/library/abbreviations/timezones/

I found nothing off by any other factor, such as 20 minutes or 44 minutes.
--

    Lindsley Williams / [EMAIL PROTECTED]


From: Allen Watson <[EMAIL PROTECTED]>
Reply-To: "Entourage:mac Talk" <[EMAIL PROTECTED]>
Date: Mon, 26 Jul 2004 14:45:44 -0700
To: "Entourage:mac Talk" <[EMAIL PROTECTED]>
Subject: Re: received message timing

On 7/26/04 2:26 PM, I wrote:

> Hm...are there some time zones that are offset to the half hour? Seems to
> me I recall seeing that somewhere. In that case, the time zone offset
> would end with "30", right?  
>

Checked, and there are: among them, Kabul, Adelaide, and Bombay, some rather important places. I'll add a check to the script to check for 00 or 30. For those who don't know what this is all about, it sets the Time Received of a message to the time/date that the message arrived at your mail server, instead of the time your copy of Entourage downloaded it, thus giving a more accurate timeline sequence for your incoming messages. You can select messages and run the script, or set up a rule to run it against all incoming messages.

-- Script from a message sent by Barry Wainwright
-- on Wednesday, July 21, 2004 3:15:13 PM

-- Correct the date v1.0 25th June 2002
-- (Modified 22/7/2004 to set Time Received to First Received Header date)
-- a script for Microsoft Entourage by Barry Wainwright
-- Resets the date of messages to the date of the first received header
-- useful for messages with badly formatted (or just plain wrong) dates

tell application "Microsoft Entourage"
    set theMessages to current messages
   if theMessages is {} then
       display dialog "No messages selected!" buttons {"Stop"} default button 1 with icon stop
       return -99
    end if
   repeat with theMess in theMessages
       set theHeaders to the headers of theMess
       set AppleScript's text item delimiters to {return & space}
        set theHeaders to text items of theHeaders
       set AppleScript's text item delimiters to {space}
        set theHeaders to theHeaders as string
       set AppleScript's text item delimiters to {return & tab}
        set theHeaders to text items of theHeaders
       set AppleScript's text item delimiters to {space}
        set theHeaders to theHeaders as string
       set theHeaders to the paragraphs of theHeaders
       set receivedHeader to ""
        repeat with aHeader in theHeaders
           if aHeader starts with "Received:" then
               copy contents of aHeader to receivedHeader
               exit repeat
           end if
       end repeat
       if receivedHeader contains ";" then
           set AppleScript's text item delimiters to {";"}
        else
           set AppleScript's text item delimiters to {","}
        end if
       set theDate to (last text item of receivedHeader)
        set GMToff to my hoursToGMTString()
        -- GMT offset usually in last word unless time zone code follows
       if last word of theDate does not end with "00" and ¬
            last word of theDate does not end with "30" then
           -- Chop off final word (time zone code)
           repeat with i from (count theDate) to 1 by -1
                if character i of theDate = " " then
                   set theDate to text 1 thru (i - 1) of theDate
                   exit repeat
               end if
           end repeat
       end if
       set theirGMToff to text -5 thru -1 of theDate
       if theirGMToffGMToff then
           tell me to set theirDate to date theDate
           set theirHoursOff to (theirGMToff as number) / 100
            set myHoursOff to (GMToff as number) / 100
            set newDate to theirDate - (theirHoursOff * hours) -- Adjust to GMT
           set newDate to newDate + (myHoursOff * hours) -- Adjust to local time
           set time received of theMess to newDate
       else
           set time received of theMess to date theDate
       end if
   end repeat
end
tell

on hoursToGMTString()
    -- Return a numeric string of the hours offset from current time zone to GMT
   -- e.g. "-0700" for Pacific Daylight Time
   set secOffset to time to GMT
   if (secOffset) � 0 then
       set temp to ((secOffset) div 60 div 60 * 100)
        if temp � 0 then
           return "+" & (text -4 thru -1 of ("0" & temp as text))
        else
           return "-" & (text -4 thru -1 of ("0" & text 2 thru -1 of (temp as text)))
        end if
   else
       return "-0000"
    end if
end
hoursToGMTString

Reply via email to