1
Vote

uialogging - LogInfo - BaseInfo - ToString() has several bugs

description

the line
        return string.Format("[{0}:{1}:{2}:{3}]",DateTime.Now.Hour.ToString("00"), DateTime.Now.Minute.ToString("00"), DateTime.Now.Second.ToString("00"), DateTime.Now.Millisecond.ToString("00").Substring(0, 2));
has the following problems:
a) DateTime.Now might change part way through, resulting in say 11:59:59:99 being displayed as 11:00:00:00, as 11:59:59:99 becoming 12:00:00:00 after 11 has been calced. if order is right to left then 11:59:59:99 might be displayed as 12:59:59:99.
b) Milliseconds of 10 displays as "10", 98 displays as "98", 100 as "10" and 980 as "98". some of these are incorrect.
These problems can be fixed by using a more compact line of
        return DateTime.Now.ToString("HH:mm:ss:ff");

comments