Formats

Meters can provide their values as either integers, real numbers or strings depending one what the specific overlay needs.

 

Overlays that require a string value can use a format specifier (defined by the meter) to tell the meter how they would like the value to be returned to them.

 

These format specifiers are documented here.

 

Many of these are simply the standard printf format strings defined by Microsoft.

 

The overlay typically embeds a special sequence of characters in a string that the meter then uses to provide its value, so for example a text overlay could have a format string like:

 

The meter value is %s!

 

If this were passed to a FixedMeter with a value of New. The overlay would display:

 

            The meter value is New!

 

The following types of format are used by various meters in SysStats:

 

Strings

Meters that require string format specifiers can use the following special characters:

 

%s

The meter value as a string!

%%

The % sign

 

Battery

The battery meter understands the following special characters:

 

%C

'Charging' - if charging

%c

'charging' - if charging

%s

'c' - if charging

%P

'AC Power' if on AC, "Battery" if on battery

%l

Label format: e.g. "AC Power", "6:28 hours (99%) remaining" etc.

%H

Time remaining in hours with a leading zero

%h

Time remaining in hours.

%M

Time remaining in minutes on the hour with a leading zero

%m

Time remaining in minutes on the hour

%T

uses '%h:%M hours' if >= 60 mins remaining, otherwise '%m minutes'

%d

percent time left (without the %)

%e

ime left in tenths

%%

the '%' sign.

 

Real Numbers

Meters that require real number format specifiers can use the following special characters. This includes the following meter types:

-       Disk

-       MBM

-       Memory

-       PDH

 

An example format would be:

 

CPU: %.0f %%

 

This means: display the string ‘CPU: ‘ followed by the value with 0 decimal places followed by a ‘%’ sign. Formats all begin with ‘%’, thus to get a percent sign you have to enter ‘%%’.

 

CPU: %02.0f %%

 

Will ensure that two digits are always printed with leading zeros (i.e. 2 % will be drawn as 02 %).

 

The format is defined by the following sequence (values in [] are optional):

 

            %[flags][width][.precision]type

 

The second optional field of the format specification is the width specification. The width argument is a nonnegative decimal integer controlling the minimum number of characters printed. If the number of characters in the output value is less than the specified width, blanks are added to the left or the right of the values — depending on whether the – flag (for left alignment) is specified — until the minimum width is reached. If width is prefixed with 0, zeros are added until the minimum width is reached (not useful for left-aligned numbers).

 

Type can be one of:

e

Signed value having the form [ – ]d.dddd e [sign]ddd where d is a single decimal digit, dddd is one or more decimal digits, ddd is exactly three decimal digits, and sign is + or –.

E

Identical to the e format except that E rather than e introduces the exponent.

f

Signed value having the form [ – ]dddd.dddd, where dddd is one or more decimal digits. The number of digits before the decimal point depends on the magnitude of the number, and the number of digits after the decimal point depends on the requested precision.

g

Signed value printed in f or e format, whichever is more compact for the given value and precision. The e format is used only when the exponent of the value is less than –4 or greater than or equal to the precision argument. Trailing zeros are truncated, and the decimal point appears only if one or more digits follow it.

G

Identical to the g format, except that E, rather than e, introduces the exponent (where appropriate).

 

Flags can be one of:

Flag

Meaning

Default

Left align the result within the given field width.

Right align.

+

Prefix the output value with a sign (+ or –) if the output value is of a signed type.

Sign appears only for negative signed values (–).

0

If width is prefixed with 0, zeros are added until the minimum width is reached. If 0 and – appear, the 0 is ignored. If 0 is specified with an integer format (i, u, x, X, o, d) the 0 is ignored.

No padding.

blank (' ')

Prefix the output value with a blank if the output value is signed and positive; the blank is ignored if both the blank and + flags appear.

No blank appears.

#

When used with the e, E, or f format, the # flag forces the output value to contain a decimal point in all cases.

Decimal point appears only if digits follow it.

 

When used with the g or G format, the # flag forces the output value to contain a decimal point in all cases and prevents the truncation of trailing zeros.

Decimal point appears only if digits follow it. Trailing zeros are truncated.

 

Precision is defined as follows:

Type

Meaning

Default

e, E

The precision specifies the number of digits to be printed after the decimal point. The last printed digit is rounded.

Default precision is 6; if precision is 0 or the period (.) appears without a number following it, no decimal point is printed.

f

The precision value specifies the number of digits after the decimal point. If a decimal point appears, at least one digit appears before it. The value is rounded to the appropriate number of digits.

Default precision is 6; if precision is 0, or if the period (.) appears without a number following it, no decimal point is printed.

g, G

The precision specifies the maximum number of significant digits printed.

Six significant digits are printed, with any trailing zeros truncated.

Integer Numbers

The integer number format specifer is defined as follows:

 

            %[flags][width][.precision]type

 

flags

+ - Print a minus sign if the value is negative and a plus sign if the value is positive.

# - Print a base indicator for hexadecimal an octal numbers

0 - Pad with leading zeros if the number does not fill the specified space (see width and/or precision below).

width

The minimum number of digits to print.

precision

The exact number of digits to print – no more, no less.

type

ld – a decimal number.

lx – a lower-case hexadecimal number

lX – an upper-case hexadecimal number

lo – an octal number

Time

The Time meter uses special formatting codes. All formatting codes begin with a ‘%’:

%a

Abbreviated weekday name

%A

Full weekday name

%b

Abbreviated month name

%B

Full month name

%c

Date and time representation appropriate for locale

%d

Day of month as decimal number (01 – 31)

%H

Hour in 24-hour format (00 – 23)

%I

Hour in 12-hour format (01 – 12)

%j

Day of year as decimal number (001 – 366)

%m

Month as decimal number (01 – 12)

%M

Minute as decimal number (00 – 59)

%p

Current locale's A.M./P.M. indicator for 12-hour clock

%S

Second as decimal number (00 – 59)

%U

Week of year as decimal number, with Sunday as first day of week (00 – 53)

%w

Weekday as decimal number (0 – 6; Sunday is 0)

%W

Week of year as decimal number, with Monday as first day of week (00 – 53)

%x

Date representation for current locale

%X

Time representation for current locale

%y

Year without century, as decimal number (00 – 99)

%Y

Year with century, as decimal number

%z, %Z

Either the time-zone name or time zone abbreviation, depending on registry settings; no characters if time zone is unknown

%%

Percent sign

 

Any number of these can be used in a single format. So for example the following displays the hour and minutes in 24 hour format:

 

            %H:%M

 

In addition the display can be modified using the ‘#’ character as follows:

 

%#a, %#A, %#b, %#B, %#p, %#X, %#z, %#Z, %#%

# flag is ignored.

%#c

Long date and time representation, appropriate for current locale. For example: "Tuesday, March 14, 1995, 12:41:29".

%#x

Long date representation, appropriate to current locale. For example: "Tuesday, March 14, 1995".

%#d, %#H, %#I, %#j, %#m, %#M, %#S, %#U, %#w, %#W, %#y, %#Y

Remove leading zeros (if any).