diff options
Diffstat (limited to 'projecttemplates/RelyingPartyLogic/Utilities.cs')
-rw-r--r-- | projecttemplates/RelyingPartyLogic/Utilities.cs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/projecttemplates/RelyingPartyLogic/Utilities.cs b/projecttemplates/RelyingPartyLogic/Utilities.cs index 47212e6..1f07a9e 100644 --- a/projecttemplates/RelyingPartyLogic/Utilities.cs +++ b/projecttemplates/RelyingPartyLogic/Utilities.cs @@ -142,5 +142,18 @@ GO" }; throw new ArgumentException("DateTime must be given in UTC time but was " + value.Kind.ToString()); } } + + /// <summary> + /// Ensures that local times are converted to UTC times. Unspecified kinds are recast to UTC with no conversion. + /// </summary> + /// <param name="value">The date-time to convert.</param> + /// <returns>The date-time in UTC time.</returns> + internal static DateTime AsUtc(this DateTime value) { + if (value.Kind == DateTimeKind.Unspecified) { + return new DateTime(value.Ticks, DateTimeKind.Utc); + } + + return value.ToUniversalTime(); + } } } |