BasicAuthentication attribute and TimeSpan.ToShortString()
- BasicAuthenticationAttribute sets the HttpContext.User property when successfully validated. - Moved BasicAuthenticationAttribute from ActionFilter to IAsyncAuthorizationFilter. - TimeSpan.ToShortString() is now capable of negative values.
This commit is contained in:
@@ -91,19 +91,22 @@ namespace System
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
|
||||
if (timeSpan.TotalDays >= 1)
|
||||
sb.Append(timeSpan.Days).Append("d ");
|
||||
if (timeSpan < TimeSpan.Zero)
|
||||
sb.Append("-");
|
||||
|
||||
if (timeSpan.TotalHours >= 1)
|
||||
sb.Append(timeSpan.Hours).Append("h ");
|
||||
if (timeSpan.TotalDays != 0)
|
||||
sb.Append(Math.Abs(timeSpan.Days)).Append("d ");
|
||||
|
||||
if (timeSpan.TotalMinutes >= 1)
|
||||
sb.Append(timeSpan.Minutes).Append("m ");
|
||||
if (timeSpan.TotalHours != 0)
|
||||
sb.Append(Math.Abs(timeSpan.Hours)).Append("h ");
|
||||
|
||||
sb.Append(timeSpan.Seconds).Append("s ");
|
||||
if (timeSpan.TotalMinutes != 0)
|
||||
sb.Append(Math.Abs(timeSpan.Minutes)).Append("m ");
|
||||
|
||||
sb.Append(Math.Abs(timeSpan.Seconds)).Append("s ");
|
||||
|
||||
if (withMilliseconds)
|
||||
sb.Append(timeSpan.Milliseconds).Append("ms");
|
||||
sb.Append(Math.Abs(timeSpan.Milliseconds)).Append("ms");
|
||||
|
||||
return sb.ToString().Trim();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user