[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Is there a POSIX compliant way of turning a "HH:MM:SS" formatted string to seconds? ...



On Fri, Jul 18, 2025 at 01:21:08AM +0200, lbrtchx@tutamail.com 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!:

I am not at all surprised. It could have been either HH:MM or MM:SS. I think
that HH:MM is reasonable/correct - but I will not argue. But you now know how it
interprets it so simply detect the NN:NN case and append :00

-- 
Alain Williams
Linux/GNU Consultant - Mail systems, Web sites, Networking, Programmer, IT Lecturer.
+44 (0) 787 668 0256  https://www.phcomp.co.uk/
Parliament Hill Computers. Registration Information: https://www.phcomp.co.uk/Contact.html
#include <std_disclaimer.h>


Reply to: