Skip to content

Instantly share code, notes, and snippets.

@beaugunderson
Created March 17, 2012 04:41
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save beaugunderson/2054996 to your computer and use it in GitHub Desktop.
Save beaugunderson/2054996 to your computer and use it in GitHub Desktop.
Human-readable long epoch dates in vim
" 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>
@beaugunderson
Copy link
Author

Screenshot

@kristjan
Copy link

Nice one

@beaugunderson
Copy link
Author

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