Skip to content

Instantly share code, notes, and snippets.

@FelipeCortez
Created September 27, 2022 08:11
Show Gist options
  • Save FelipeCortez/ed36cf0a4cd1ded6ee28fec373f886ca to your computer and use it in GitHub Desktop.
Save FelipeCortez/ed36cf0a4cd1ded6ee28fec373f886ca to your computer and use it in GitHub Desktop.
(comment
(import '[java.time Duration])
@(def subs (slurp "/Users/felipecortez/suboverride.ttml"))
(spit "/Users/felipecortez/suboverride-good.ttml"
(clojure.string/replace subs #"\d\d:\d\d:\d\d\.\d\d\d" shifted)))
(defn shifted [cue-timing]
(let [[h m s ms] (map #(Integer/parseInt % 10) (str/split cue-timing #"[:.]"))
shifted-ts (-> (Duration/ofMillis (+ ms (* 1000 s) (* 60 1000 m) (* 60 60 1000 h)))
(.minusSeconds 6)
(.minusMillis 800))]
(format "%02d:%02d:%02d.%03d"
(.toHoursPart shifted-ts)
(.toMinutesPart shifted-ts)
(.toSecondsPart shifted-ts)
(.toMillisPart shifted-ts))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment