Re: [MlMt] Mail Date and UTC
On 23 Sep 2014, at 15:35, Alexander Kucera wrote: I have a test email whose raw headers show the date as `Date: Tue, 23 Sep 2014 13:03:13 +` which is what is written into the variable I get from MailMate. However I live in UTC+2 so the time I should be putting into the log is `15:03:13`. MailMate displays this correctly in the UI, but passes the raw time value to the bundle, which is fine I guess, but I am unable to convert in in any way that makes sense due to a lack of Ruby/programming knowledge. A little help please? You should pass the virtual `#date` value instead of the raw date of the message. That way you'll leave it to MailMate to generate a canonically formatted date instead of the numerous badly formatted dates used in emails. After that, you can probably make Ruby parse it and format it in any way you like (I haven't checked how this works in Ruby). On the command line, you can do it like this: date -j -f %Y-%m-%d %T %z 2014-01-01 10:10:10 + +%a %b %d %T %Y The format strings are described in `man strftime`. -- Benny ___ mailmate mailing list mailmate@lists.freron.com http://lists.freron.com/listinfo/mailmate
Re: [MlMt] Mail Date and UTC
I have Ruby's date parsing working already, just on the raw date. The existence of #date is a huge relief. While we are on the topic of Ruby. Is there any reason all the bundles are in Ruby? Would any language work? I am much more comfortable in Python for example. Alexander Kucera \ Lighting TD Compositor — Founder Lead Artist at BabylonDreams — The Foundry certified Nuke Trainer \ Neustadt, Germany GMT +1 \ App.net: AlexK \ Skype: marvinthemartian On 24 Sep 2014, at 10:25, Benny Kjær Nielsen wrote: On 23 Sep 2014, at 15:35, Alexander Kucera wrote: I have a test email whose raw headers show the date as `Date: Tue, 23 Sep 2014 13:03:13 +` which is what is written into the variable I get from MailMate. However I live in UTC+2 so the time I should be putting into the log is `15:03:13`. MailMate displays this correctly in the UI, but passes the raw time value to the bundle, which is fine I guess, but I am unable to convert in in any way that makes sense due to a lack of Ruby/programming knowledge. A little help please? You should pass the virtual `#date` value instead of the raw date of the message. That way you'll leave it to MailMate to generate a canonically formatted date instead of the numerous badly formatted dates used in emails. After that, you can probably make Ruby parse it and format it in any way you like (I haven't checked how this works in Ruby). On the command line, you can do it like this: date -j -f %Y-%m-%d %T %z 2014-01-01 10:10:10 + +%a %b %d %T %Y The format strings are described in `man strftime`. -- Benny ___ mailmate mailing list mailmate@lists.freron.com http://lists.freron.com/listinfo/mailmate ___ mailmate mailing list mailmate@lists.freron.com http://lists.freron.com/listinfo/mailmate
Re: [MlMt] Mail Date and UTC
On 24 Sep 2014, at 10:32, Alexander Kucera wrote: While we are on the topic of Ruby. Is there any reason all the bundles are in Ruby? No. Would any language work? Yes. (As long as it can read environment variables and handle input and output in UTF8.) I am much more comfortable in Python for example. It's an important part of the bundle system that you can use any language you like. -- Benny ___ mailmate mailing list mailmate@lists.freron.com http://lists.freron.com/listinfo/mailmate
Re: [MlMt] Mail Date and UTC
On 24 Sep 2014, at 11:14, Alexander Kucera wrote: Hmm, I'm not sure #date is working correctly. I have a raw date of `Tue, 23 Sep 2014 17:38:44 -0500`, but #date seems to give me the exact same thing only formatted differently. When I print #date I get `2014-09-23 17:38:44 -0500` instead of `2014-09-24 00:38:44 +` which MailMate shows me. So I still would need to do some timezone script foo to get my log entries straight. Or did I maybe not understand the purpose of #date correctly? The purpose is that your scripting language should be able to parse this date without problems. Since the time zone is included then the date and time is non-ambiguous. You should then use the scripting language to format the date according to the local time zone. Here is a variant from my previous example: TZ=CET date -j -f %Y-%m-%d %T %z 2014-01-01 10:10:10 -0500 +%a %b %d %T %Y Here I first explicitly state that we are in zone CET (`+0100`). (I don't really need to do that since that is also the default *for me*.) The date and time is given in zone `-0500`. So, at GMT (`+`) the time would be `15:10:10`, and in zone `+0100` this would be `16:10:10`. This is also the result of the command above. Time zones are confusing and daylight saving times do not make it easier. (I often make mistakes when dealing with time zones.) There is no virtual header available for the current time zone. If there were then it would have to be dynamic (not cached/saved to disk) in the event that you were travelling between time zones. You can also use `#date-received` I believe. This is “hardcoded” to timezone + if that makes it easier. -- Benny ___ mailmate mailing list mailmate@lists.freron.com http://lists.freron.com/listinfo/mailmate
Re: [MlMt] Mail Date and UTC
Ah, I see. Time to dive into the depths of timezone conversion then I guess. Thanks Benny. Alexander Kucera \ Lighting TD Compositor — Founder Lead Artist at BabylonDreams — The Foundry certified Nuke Trainer \ Neustadt, Germany GMT +1 \ App.net: AlexK \ Skype: marvinthemartian On 24 Sep 2014, at 12:38, Benny Kjær Nielsen wrote: On 24 Sep 2014, at 11:14, Alexander Kucera wrote: Hmm, I'm not sure #date is working correctly. I have a raw date of `Tue, 23 Sep 2014 17:38:44 -0500`, but #date seems to give me the exact same thing only formatted differently. When I print #date I get `2014-09-23 17:38:44 -0500` instead of `2014-09-24 00:38:44 +` which MailMate shows me. So I still would need to do some timezone script foo to get my log entries straight. Or did I maybe not understand the purpose of #date correctly? The purpose is that your scripting language should be able to parse this date without problems. Since the time zone is included then the date and time is non-ambiguous. You should then use the scripting language to format the date according to the local time zone. Here is a variant from my previous example: TZ=CET date -j -f %Y-%m-%d %T %z 2014-01-01 10:10:10 -0500 +%a %b %d %T %Y Here I first explicitly state that we are in zone CET (`+0100`). (I don't really need to do that since that is also the default *for me*.) The date and time is given in zone `-0500`. So, at GMT (`+`) the time would be `15:10:10`, and in zone `+0100` this would be `16:10:10`. This is also the result of the command above. Time zones are confusing and daylight saving times do not make it easier. (I often make mistakes when dealing with time zones.) There is no virtual header available for the current time zone. If there were then it would have to be dynamic (not cached/saved to disk) in the event that you were travelling between time zones. You can also use `#date-received` I believe. This is “hardcoded” to timezone + if that makes it easier. -- Benny ___ mailmate mailing list mailmate@lists.freron.com http://lists.freron.com/listinfo/mailmate ___ mailmate mailing list mailmate@lists.freron.com http://lists.freron.com/listinfo/mailmate