Skip to content

Instantly share code, notes, and snippets.

@kunev
Last active September 14, 2015 17:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kunev/d8b46a1103e26e8f4082 to your computer and use it in GitHub Desktop.
Save kunev/d8b46a1103e26e8f4082 to your computer and use it in GitHub Desktop.
display date header in local time in mutt
#!/usr/bin/env python
# Save this in a file somewhere
# In your mutt config add the following line
# set display_filter="/PATH/TO/THIS/PYTHON/FILE"
import sys
import re
import os
message = sys.stdin.read()
in_headers = True
for line in message.split('\n'):
if line == '':
in_headers = False
match = re.match(r'^Date: (.+$)', line)
if in_headers and match:
date_string = match.group(1)
converted_date = os.popen('date -d "{}"'.format(date_string)).read()
print('Date: {}'.format(converted_date.strip()))
else:
print(line)
@ysangkok
Copy link

i made a python 3.3 version at http://unix.stackexchange.com/a/229619/14305

you are not escaping the shell argument properly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment