const (
myname = "pstop"
- copyright = "Copyright (C) 2014 Simon J Mudd <sjmudd@pobox.com>"
+ copyright = "Copyright (C) 2014-2015 Simon J Mudd <sjmudd@pobox.com>"
i_1024_2 = 1024 * 1024
i_1024_3 = 1024 * 1024 * 1024
i_1024_4 = 1024 * 1024 * 1024 * 1024
return fmt.Sprintf("%02d:%02d:%02d", hours, minutes, seconds)
}
+// similar to sec_to_time() spaces if 0 and takes seconds as input.
+func FormatSeconds(seconds uint64) string {
+ if seconds == 0 {
+ return " "
+ } else {
+ return sec_to_time(seconds)
+ }
+}
+
// FormatTime is based on sys.format_time. It
// formats to 10 characters including space and suffix.
// All values have 2 decimal places. Zero is returned as
return formatted
}
+// like Amount but tigher in space
+func FormatCounter(counter int, width int) string {
+ if counter == 0 {
+ pattern := "%" + fmt.Sprintf("%d", width) + "s"
+ return fmt.Sprintf(pattern, " ")
+ } else {
+ pattern := "%" + fmt.Sprintf("%d", width) + "d"
+ return fmt.Sprintf(pattern, counter)
+ }
+}
+
// MyDivide() divides a by b except if b is 0 in which case we return 0.
func MyDivide(a uint64, b uint64) float64 {
if b == 0 {