public static long ToUnixDate(this DateTime self)
{
if (self == DateTime.MinValue)
{
return 0;
}
DateTime epoch = new DateTime(1970, 1, 1);
TimeSpan delta = self - epoch;
if (delta.TotalSeconds < 0)
{
throw new ArgumentOutOfRangeException(Error.InvalidUnixEpochErrorMessage);
}
return (long)delta.TotalSeconds;
}