You've already forked linux-packaging-mono
Imported Upstream version 4.6.0.125
Former-commit-id: a2155e9bd80020e49e72e86c44da02a8ac0e57a4
This commit is contained in:
parent
a569aebcfd
commit
e79aa3c0ed
52
mcs/class/referencesource/System.Web/Util/DateTimeUtil.cs
Normal file
52
mcs/class/referencesource/System.Web/Util/DateTimeUtil.cs
Normal file
@ -0,0 +1,52 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <copyright file="FileChangesMonitor.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace System.Web.Util {
|
||||
|
||||
using System;
|
||||
|
||||
internal sealed class DateTimeUtil {
|
||||
private DateTimeUtil() {}
|
||||
|
||||
const long FileTimeOffset = 504911232000000000;
|
||||
static readonly DateTime MinValuePlusOneDay = DateTime.MinValue.AddDays(1);
|
||||
static readonly DateTime MaxValueMinusOneDay = DateTime.MaxValue.AddDays(-1);
|
||||
|
||||
static internal DateTime FromFileTimeToUtc(long filetime) {
|
||||
long universalTicks = filetime + FileTimeOffset;
|
||||
// Dev10 733288: Caching: behavior change for CacheDependency when using UseMemoryCache=1
|
||||
// ObjectCacheHost converts DateTime to a DateTimeOffset, and the conversion requires
|
||||
// that DateTimeKind be set correctly
|
||||
return new DateTime(universalTicks, DateTimeKind.Utc);
|
||||
}
|
||||
|
||||
static internal DateTime ConvertToUniversalTime(DateTime localTime) {
|
||||
if (localTime < MinValuePlusOneDay) {
|
||||
return DateTime.MinValue;
|
||||
}
|
||||
|
||||
if (localTime > MaxValueMinusOneDay) {
|
||||
return DateTime.MaxValue;
|
||||
}
|
||||
|
||||
return localTime.ToUniversalTime();
|
||||
}
|
||||
|
||||
static internal DateTime ConvertToLocalTime(DateTime utcTime) {
|
||||
if (utcTime < MinValuePlusOneDay) {
|
||||
return DateTime.MinValue;
|
||||
}
|
||||
|
||||
if (utcTime > MaxValueMinusOneDay) {
|
||||
return DateTime.MaxValue;
|
||||
}
|
||||
|
||||
return utcTime.ToLocalTime();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user