Added constants defining DateTime range
This commit is contained in:
@@ -41,6 +41,7 @@
|
||||
<ItemGroup>
|
||||
<Compile Include="Attributes\DbEnumField.cs" />
|
||||
<Compile Include="Attributes\DbRecordType.cs" />
|
||||
<Compile Include="Constants.cs" />
|
||||
<Compile Include="Enums\AddressValidationResult.cs" />
|
||||
<Compile Include="Enums\AutoMailType.cs" />
|
||||
<Compile Include="Enums\CommunicationType.cs" />
|
||||
@@ -71,6 +72,9 @@
|
||||
<Compile Include="Enums\RoleTypeClass.cs" />
|
||||
<Compile Include="Exceptions\ConcurrencyException.cs" />
|
||||
<Compile Include="Exceptions\DatabaseConcurrencyException.cs" />
|
||||
<Compile Include="ExtensionMethods\Bitmap.cs" />
|
||||
<Compile Include="ExtensionMethods\Color.cs" />
|
||||
<Compile Include="ExtensionMethods\DateTime.cs" />
|
||||
<Compile Include="Generics\Tree.cs" />
|
||||
<Compile Include="Interfaces\IEmailPerson.cs" />
|
||||
<Compile Include="Interfaces\IHandleProvider.cs" />
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Swarmops.Common
|
||||
{
|
||||
public class Constants
|
||||
{
|
||||
// These constants are necessary because MySql keeps vomiting on DateTime.MinValue and DateTime.MaxValue, so we
|
||||
// need some other definition of endpoints of the valid DateTime space
|
||||
|
||||
public static DateTime DateTimeLow
|
||||
{ get { return new DateTime(1800, 1, 1); } }
|
||||
|
||||
public static DateTime DateTimeHigh
|
||||
{ get { return new DateTime(2300, 12, 1); } }
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.Eventing.Reader;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
@@ -14,5 +15,27 @@ namespace Swarmops.Common.ExtensionMethods
|
||||
|
||||
return (Int32)(source.Subtract(new DateTime(1970, 1, 1, 0, 0, 0,DateTimeKind.Utc))).TotalSeconds;
|
||||
}
|
||||
|
||||
public static bool IsHigh(this DateTime source)
|
||||
{
|
||||
if (source.Year > 2299) return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static bool IsLow(this DateTime source)
|
||||
{
|
||||
if (source.Year < 1801) return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static bool IsDefined(this DateTime source)
|
||||
{
|
||||
if (source.IsHigh()) return false;
|
||||
if (source.IsLow()) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,9 +115,6 @@
|
||||
<Compile Include="Communications\IHasGeography.cs" />
|
||||
<Compile Include="Communications\Resolution\ParticipantResolver.cs" />
|
||||
<Compile Include="Communications\Resolution\ResolverEnvelope.cs" />
|
||||
<Compile Include="ExtensionMethods\Bitmap.cs" />
|
||||
<Compile Include="ExtensionMethods\Color.cs" />
|
||||
<Compile Include="ExtensionMethods\DateTime.cs" />
|
||||
<Compile Include="Financial\BitcoinTransactionInput.cs" />
|
||||
<Compile Include="Financial\BitcoinUtility.cs" />
|
||||
<Compile Include="Financial\HotBitcoinAddress.cs" />
|
||||
|
||||
Reference in New Issue
Block a user