On Thu 17 Jul 2025 at 23:39:02 (+0200), [email protected] wrote:
> Video durations are formatted in youtube's .info.json files as "HH:MM:SS";
        ↑↑↑↑↑↑↑↑↑

On Fri 18 Jul 2025 at 01:21:08 (+0200), [email protected] wrote:
> OK, the Math is right, but the assumptions made by date aren't smart. I 
> "overtested" your one liner with the kinds of input you would grab using jq 
> from youtube .info.json files and to my amazement, when you only have two 
> semicolon separated values, the bash date utility assumes the first chunk to 
> be the hours and the second the minutes!:

Times that are associated with dates, as in the date utility,
are times of day, and these have to include an hour value
in the range 0 through 24.

For times that are durations, there's no such rule, and
youtube's notation is just a sensible convention for measuring
videos. It would be useless for giving the reverberation time
of a concert hall, or the duration of a journey to Pluto.

> I still think that there should be a way to make what I need straight forward 
> using date's own formatting.

Your starting point with date would be the /time/:

  $ TZ=UTC date --date='@0' +'%s'
  0
  $ 

and then you would add /durations/ by using what is outlined
in the section headed 'Relative items in date strings' from:

  $ info date
  … …

However, I don't /think/ that date can syntactically handle a --date
argument of that complexity (mixing an absolute and relative time),
so using date at all is just a nasty hack.

Cheers,
David.

Reply via email to