decimal time
LucasLarson opened this issue · 2 comments
LucasLarson commented
Leah Neukirchen serves decimal time using Ruby;1 this utility should be available here, too, but should use only POSIX-defined tools and options
Footnotes
LucasLarson commented
This works, even on System V:
#!/bin/sh
# get current 24-hour time with seconds
LC_ALL='C' date '+%H %M %S' |
awk -- '{
# get the percentage of seconds that have passed so far today
percentage = ($1 * 60 * 60 + $2 * 60 + $3) / (24 * 60 * 60)
# print the content after the decimal point but
# insert colons after the tenths (decimal hours) and thousandths (decimal minutes)
printf "%d:%02d:%02d\n", substr(percentage, 3, 1), substr(percentage, 4, 2), substr(percentage, 6, 2)
}'
LucasLarson commented
fixed in #766 and fa1514e171