The styles parameter affects the interpretation of strings parsed using custom format strings. It determines whether input is interpreted as a negative time interval only if a negative sign is present (TimeSpanStyles.None), or whether it is always interpreted as a negative time interval (TimeSpanStyles.AssumeNegative). If TimeSpanStyles.AssumeNegative is not used, format must include a literal negative sign symbol (such as "-") to successfully parse a negative time interval.
I have try the following:
TimeSpan.ParseExact("-0700", @"\-hhmm", null, TimeSpanStyles.None)
However it returns 07:00:00. And fails for "0700".
If I try:
TimeSpan.ParseExact("-0700", "hhmm", null, TimeSpanStyles.None)
It fails too.
TimeSpan.ParseExact("0700", new string [] { "hhmm", @"\-hhmm" }, null, TimeSpanStyles.None)
Does not fail for both "0700" and "-0700", but always return the positive 07:00:00.
How is it supposed to be used?
Duration
in Noda Time. Will see what I can do withTimeSpan
though... – Geraldine