private unsafe static void FormatDigits(StringBuilder outputBuffer, int value, int len) {
BCLDebug.Assert(value >= 0, "DateTimeFormat.FormatDigits(): value >= 0");
// Limit the use of this function to be two-digits, so that we have the same behavior
// as RTM bits.
if (len > 2)
{
len = 2;
}
char* buffer = stackalloc char[16];
char* p = buffer + 16;
int n = value;
do {
*--p = (char)(n % 10 + '0');
n /= 10;
} while ((n != 0)&&(p > buffer));
int digits = (int) (buffer + 16 - p);
//If the repeat count is greater than 0, we're trying
//to emulate the "00" format, so we have to prepend
//a zero if the string only has one character.
while ((digits < len) && (p > buffer)) {
*--p='0';
digits++;
}
outputBuffer.Append(p, digits);
}