Time Zones in Mac Mail

I have been using AppleScript to print individual emails to PDF as printing a large selection from the app seems unreliable. Along the way I have had trouble with message reception times.

The app seems to display the local time when the message was received. There is a time zone in the Date header, as expected, but not in dates pulled out in AppleScript, as far as I can tell.

The SQLite DB seems to have times in UTC but I cannot see how to get at the time zone.

This probably seems rather obscure but I am hoping someone can suggest how I can tell the time zone. For me that will switch from GMT to BST over the year. Parsing the headers seems the only way at the moment.

Time zone of what?

The headers of your messages will take the time zone into account. For example, I’m in the eastern time zone (-5) and a message I receive today will have -0500 in the headers while the displayed time received of the message will be my local time.

If I get a message in June however, it wlll be EDT here and the headers will then indicate -0400 and the displayed time received for message will be the then local time.

Applescript has a time to GMT command which gives the number of seconds away from GMT. In my case, that is currently -18000 or -5 hours. For you, it would likely be 0 today but come April, would be -3600 or -1 hour.

1 Like

Thanks.

It is the AppleScript (and Mail app) dates/times that don’t have a time zone, but the message headers do - a time offset and maybe a timezone code.

Checking headers just now it seems:

In the Mail app: View>Message>Default Headers does not show a Date line; View>Message>Raw Source shows the original Date line. From a friend in Oregon, to me in the UK an example is:
Date: Sun, 17 Dec 2023 19:33:00 -0800

Using AppleScript and accessing the ‘source’ of the message I get the same. But scanning ‘all headers’ of the message I get the time rewritten to my local zone:
Date: 18 December 2023 at 03:33:00 GMT.
The ‘date sent’ for the message is the same.

All a bit strange but if I look at messages when DST is in play, I get dates with BST (no surprise). AppleScript and the Mail app report the local time even in BST. However, going to sqlite I get dates in UTC which means that during GMT both match, but during BST they differ by an hour.

It only matters because I wanted to use to use the sent or received date in the name of printed files but I can’t easily match them up with a date via sqlite.

My aim now is to find if I am getting BST or GMT and try to offset the BST values by an hour to be UTC (~GMT).

All very niche, I realise!

Thanks. That gives me the info to handle it properly!

At the moment I am trying a hack. As my zone is GMT/BST it seems Mail always maps date records to whichever is current (even when I am outside my zone). The last word of the header is one of the two, so for me I am subtracting ‘hours’ from a BST time.