Function: hsys-youtube-time-in-seconds

hsys-youtube-time-in-seconds is an autoloaded and byte-compiled function defined in hsys-youtube.el.

Signature

(hsys-youtube-time-in-seconds START-TIME-STRING)

Documentation

Return the number of seconds time for a Youtube url given a START-TIME-STRING.

Hours and minutes are optional within the START-TIME-STRING, e.g. 1:2:44 (1 hour, two minutes, 45 seconds into a video). The formats 1h2m44s or 1h:2m:44s may also be used. If the START-TIME-STRING format is invalid, return it unchanged.

Source Code

;; Defined in ~/.emacs.d/elpa/hyperbole-20260414.325/hsys-youtube.el
;;;###autoload
(defun hsys-youtube-time-in-seconds (start-time-string)
  "Return the number of seconds time for a Youtube url given a START-TIME-STRING.
Hours and minutes are optional within the START-TIME-STRING,
e.g. 1:2:44 (1 hour, two minutes, 45 seconds into a video).  The
formats 1h2m44s or 1h:2m:44s may also be used.  If the
START-TIME-STRING format is invalid, return it unchanged."
  (if (and (stringp start-time-string)
	   (string-match-p "[:hmsHMS]" start-time-string))
      (let* ((time-parts (split-string start-time-string "[:hmsHMS]" t))
             (num-of-parts (length time-parts))
	     (part1 (nth 0 time-parts))
	     (part2 (nth 1 time-parts))
	     (part3 (nth 2 time-parts)))
        (cond ((zerop num-of-parts)
               "0")
              ((= num-of-parts 1)
               part1)
              ((= num-of-parts 2)
	       (int-to-string (+ (* (string-to-number part1) 60)
				 (string-to-number part2))))
              ((= num-of-parts 3)
	       (int-to-string (+ (* (string-to-number part1) 3600)
				 (* (string-to-number part2) 60)
				 (string-to-number part3))))))
    start-time-string))