Closed mathstuf closed 13 years ago
Can you elaborate on your motives for this? For complete functionality, d<C-A>
and d<C-X>
(which set the time under the cursor to the current time) need to be hooked up, So, if you're really after milliseconds, I'd sooner leave off nanoseconds. I don't think I've ever cared about anything more precise than microseconds. Ever.
According to that link and confirmed interactively, Python's %f
actually does microseconds, not milliseconds. Which is good, because Ruby has only the awkward %6N
which is incompatible with our gimped strftime.
I meant to explicitly state that Vim only provides microsecond time precision, meaning that d<C-A>
and d<C-X>
would have to zero-pad a nanosecond field. Not the end of the world, mind you, but I'd rather avoid it unless nanoseconds really are crucial.
If I don't here back in the next week or so, I'll probably tackle adapting this to microseconds myself.
Ah. Misread the millisecond/microsecond detail. My motivation was the editing of subtitle files which have millisecond precision and I had to offset chapters by the previous chapter times. Making a macro to decrease the times reliably made things go a lot faster.
Working on microseconds now.
Hmm. I can't find how to get milliseconds from Vim. It uses the system's strftime and is therefore not portable and I don't see it in my strftime manpage. Leaving sub-second fields zero if set from "now" is fine by me.
Against all odds, I found myself editing subtitles last night, and this worked pretty well. It completely breaks d<C-X>
(but not d<C-A>
, bizarrely), so that needs to be fixed before it can be merged in.
Getting microseconds out of Vim is a simple matter of reltimestr(reltime())
.
I'll look at this closer tomorrow or so.
Okay, after a lot of monkeying and banging my head against the wall, I've simplified to only handling milliseconds. I'll worry about microseconds and nanoseconds once there's a real use case for them. Thanks for the patch!
Add %L and %N specifiers similar to Ruby[1]. Python uses %f for milliseconds[2]. Should this be supported as well?
[1]http://redmine.ruby-lang.org/repositories/diff/ruby-19?rev=18731 [2]http://bugs.python.org/issue1982