Property | Value |
---|---|
Id | AN0009 |
Category | Formatting |
Default Severity | Warning |
When formatting a TimeSpan
using one the following is always invalid:
Year and month does not apply TimeSpan
y
Y
yy
yyy
yyyy
M
"Did you meanmm
(minutes)"MM
"Did you meanmm
(minutes)"MMM
MMMM
TimeSpan
doesn't operator with 12 vs 24h clock, so this is invalid:
-
HH
"Did you meanhh
(hours)" -
D
"Did you meandd
(days)" -
DD
"Did you meandd
(days)"
Special cases:
d
alone doesn't work, use%d
or in a pattern@"d\:h"
h
alone doesn't work, use%h
or in a pattern@"h\:m"
m
alone doesn't work, use%d
or in a pattern@"m\:s"
s
alone doesn't work, use%s
or in a pattern@"s\:f"
f
alone doesn't work, use%f
or in a pattern@"f\:ff"
F
alone doesn't work, use%F
or in a pattern@"F\:ff"
var time = new TimeSpan(0, 10, 5).ToString(@"M", CultureInfo.InvariantCulture); // AN0009 - Month not valid in TimeSpan formatting. Did you mean 'm' (minutes)?
var time = new TimeSpan(0, 10, 5).ToString(@"m", CultureInfo.InvariantCulture);