MSDN says :
The styles parameter affects the interpretation of strings parsed using custom-format strings. It determines whether an input is interpreted as a negative time interval only if a negative sign is present (TimeSpanStyles.None), or it is always interpreted as a negative time interval (TimeSpanStyles.AssumeNegative). If TimeSpanStyles.AssumeNegative is not used, the format must contain a negative letter character (for example, “-”) for successful analysis of the negative time interval.
I will try the following:
TimeSpan.ParseExact("-0700", @"\-hhmm", null, TimeSpanStyles.None)
However, he returns 07:00:00. And does not work for "0700."
If I try:
TimeSpan.ParseExact("-0700", "hhmm", null, TimeSpanStyles.None)
Crash too.
TimeSpan.ParseExact("0700", new string [] { "hhmm", @"\-hhmm" }, null, TimeSpanStyles.None)
It does not work for both "0700" and "-0700", but always returns positive 07:00:00.
How should it be used?
source share