[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 Jul 18, 2025, lbrtchx@tutamail.com wrote:
> OK, it makes some more sense now. The range of digits in the octal
> system is from 0 to 7, so it would complain with "08" and "09" (but
> not with "10" which would then be "8" in octal), but why would command
> line utilities assume you are encoding numeric values as octal? Now I
> notice many people have stumble on the same problem. There should be a
> straight forward way to encode from "HH:MM:SS" to seconds. I doubt
> that the date utility would assume you are computing numbers as
> octal.

As I recall, this is a holdover from languages that predate C that an
explicit leading zero indicated octal notation.

Decimal 7 => 7
Octal 7 => 07
Character 7 => '7'

-- 
|_|O|_| 
|_|_|O| Github: https://github.com/dpurgert
|O|O|O| PGP: DDAB 23FB 19FA 7D85 1CC1  E067 6D65 70E5 4CE7 2860

Attachment: signature.asc
Description: PGP signature


Reply to: