Skip to content

Instantly share code, notes, and snippets.

@acarrillo
Created July 31, 2012 21:48
Show Gist options
  • Save acarrillo/3220925 to your computer and use it in GitHub Desktop.
Save acarrillo/3220925 to your computer and use it in GitHub Desktop.
A simple filter for converting UNIX epoch timestamps to a more readable format -- works great with Vim!
#!/usr/bin/env python
'''A filter that takes a UNIX epoch timestamp as input, and outputs the date in a more human-friendly format
Put this file somewhere in your PATH and 'chmod +x' it.
In your ~/.vimrc:
vnoremap <silent> <F6> :!datefiltr.py<CR>
'''
import fileinput
from time import strftime, gmtime
__author__ = 'Kevin Wang and Alex Carrillo'
output = ''
for line in fileinput.input():
output += strftime("%c",gmtime(int(line))) + ('\n' if line[-1] == '\n' else '')
print output
@acarrillo
Copy link
Author

@kevinwang -- woo!

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