~statianzo/timeshift

6f3221b799b585ab5ef463515863a199e69bdde8 — Jason Staten 2 years ago
first
2 files changed, 30 insertions(+), 0 deletions(-)

A go.mod
A main.go
A  => go.mod +3 -0
@@ 1,3 @@
module git.sr.ht/~statianzo/timeshift

go 1.14

A  => main.go +27 -0
@@ 1,27 @@
package main

import (
	"bufio"
	"fmt"
	"os"
	"time"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	for scanner.Scan() {
		line := scanner.Text()
		if len(line) < 9 {
			fmt.Print("\n")
		} else {
			timestamp := line[0:9]
			rest := line[9:]
			parsed, err := time.Parse("0:04:05.0", timestamp)
			if err != nil {
				panic(err)
			}
			incremented := parsed.Add(11 * time.Second)
			fmt.Printf("%s%s\n", incremented.Format("0:04:05.0"), rest)
		}
	}
}