parse timeStr function now returns milliseconds.

This commit is contained in:
onyx-and-iris 2026-01-09 19:04:59 +00:00
parent b0437b1656
commit dca8bc5ffc
2 changed files with 10 additions and 4 deletions

View File

@ -23,7 +23,7 @@ type MediainputSetCursorCmd struct {
// Run executes the command to set the cursor position of the media input.
func (cmd *MediainputSetCursorCmd) Run(ctx *context) error {
position, err := parseTimeStringToSeconds(cmd.TimeString)
position, err := parseTimeStringToMilliseconds(cmd.TimeString)
if err != nil {
return fmt.Errorf("failed to parse time string: %w", err)
}
@ -36,7 +36,13 @@ func (cmd *MediainputSetCursorCmd) Run(ctx *context) error {
return fmt.Errorf("failed to set media input cursor: %w", err)
}
fmt.Fprintln(ctx.Out, "Set media input cursor to position (seconds):", position)
fmt.Fprintf(
ctx.Out,
"Set %s cursor to %s (%.0f ms)\n",
ctx.Style.Highlight(cmd.InputName),
ctx.Style.Highlight(cmd.TimeString),
position,
)
return nil
}

View File

@ -39,7 +39,7 @@ func trimPrefix(s, prefix string) string {
return s
}
func parseTimeStringToSeconds(timeStr string) (float64, error) {
func parseTimeStringToMilliseconds(timeStr string) (float64, error) {
parts := strings.Split(timeStr, ":")
var durationStr string
@ -62,5 +62,5 @@ func parseTimeStringToSeconds(timeStr string) (float64, error) {
return 0, fmt.Errorf("failed to parse duration: %w", err)
}
return duration.Seconds(), nil
return duration.Seconds() * 1000, nil
}