I have a file with a lot of data in it, one being a last-modified=”1231231231″
where 1231231231 is epoch time in milliseconds
<Translation
author_id="25"
id="02f18edd-ef7a-48e2-b614-b5888936017e"
language="de_DE"
last_modified="1325669156960"
phase="1"
target="[ phase="1" language="de_DE" ]"
translation_text="Funktionen"/>
Note the: last_modified=”1325669156960″
I can run this:
:%s/\([0-9]\{10\}\)\([0-9]\{3\}\)/\1/g
to find all these occurrences and replace them with a “seconds” string:
last_modified=”1325669156″
I can then pattern match on those 10 digits, and what I’d like to do is pipe them to the unix data -d command to return a formatted data stamp:
:%s/[0-9]\{10\}/&/g
In this example, instead of replacing with the same value as I found (I.e, the &),
I’d like to somehow pipe that value to what would be essentially:
date -d &
and return that as a formatted time stamp in the
last_modified="Wed Jan 4 07:13:32 MST 2012"
Any ideas on how to do this? I have to do this about every other week on various files.
You can use
strftime()in vim. Find one proper format string to meet your needs.I’m using
%chere:result: