Skip to content

Commit 5c55f2d

Browse files
committed
seek-to: Add support for dot separated timestamps
Nothing to add here, the code is fully his. To quote from the original commit message: For best results use at least 3 digits for milliseconds (.000) or a full timestamp HH.MM.SS.sss (00.00.00.1): 00.11.31.527 11.11.11.2 1.23.11.5 00.61.611 11.30.527 11.30.000 61.61 (this will be treated as 1m1s610ms) Credit: Sneakpeakcss@85a3b63
1 parent ccb41fe commit 5c55f2d

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

scripts/seek-to.lua

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,8 +278,21 @@ end
278278
function paste_timestamp()
279279
local clipboard = get_clipboard()
280280
if clipboard == nil then return end
281+
local clipboard = clipboard:gsub("[\r\n]", "")
281282
local back_seek = clipboard:sub(1, 1) == "-"
282283

284+
-- Support for dot separated timestamps
285+
if clipboard:match("%d+%.%d+%.%d+%.?%d*") then
286+
local segment_count = select(2, clipboard:gsub("%.", "")) + 1
287+
if segment_count == 4 then
288+
clipboard = clipboard:gsub("(%d+)%.(%d+)%.(%d+)%.", "%1:%2:%3.")
289+
elseif segment_count == 3 then
290+
clipboard = clipboard:match("%.(%d%d%d)$") and
291+
clipboard:gsub("(%d+)%.(%d+)%.", "%1:%2.") or
292+
clipboard:gsub("(%d+)%.(%d+)%.(%d+)", "%1:%2:%3")
293+
end
294+
end
295+
283296
local hours, minutes, seconds, milliseconds = clipboard:match("(%d+):(%d+):(%d+)%.?(%d*)")
284297
if not hours then
285298
minutes, seconds, milliseconds = clipboard:match("(%d+):(%d+)%.?(%d*)")

0 commit comments

Comments
 (0)