Created
March 17, 2012 04:41
-
-
Save beaugunderson/2054996 to your computer and use it in GitHub Desktop.
Human-readable long epoch dates in vim
This file contains 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
" Human-readable long epoch dates (long meaning those that include milliseconds) | |
function! DateFromLongEpoch() | |
" Let the shell divide because vim only supports 32 bit ints | |
let sdate=system("echo $((". expand("<cword>") ."/1000))") | |
" Format the date | |
let human=tolower(substitute(strftime("%m/%d/%y %I:%M:%S%p", sdate), "\\\<0", "", "g")) | |
return human ." (". (sdate - localtime()) ." seconds from now)" | |
endfunc | |
map <leader>j :echo DateFromLongEpoch()<CR> |
Author
beaugunderson
commented
Mar 17, 2012
Nice one
I gave it a repo for easy Pathogen-ification: https://github.com/beaugunderson/vim-human-dates
(I also fixed the faulty regex)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment