Last active
September 14, 2015 17:02
-
-
Save kunev/d8b46a1103e26e8f4082 to your computer and use it in GitHub Desktop.
display date header in local time in mutt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
i made a python 3.3 version at http://unix.stackexchange.com/a/229619/14305
you are not escaping the shell argument properly.