diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1532f59..633af8b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
### Added
- Added Get and Set extensions to PropertyInfo in SIMPLSHARP to mimic overloads avaliable in NETSTANDARD
- Added Collection extensions for setting and adding ranges of items
+ - Added a method for getting the total number of seconds in a date
### Changed
- Repeater changed to use configured callbacks instead of a dumb event
diff --git a/ICD.Common.Utils/Extensions/DateTimeExtensions.cs b/ICD.Common.Utils/Extensions/DateTimeExtensions.cs
index 697c5e8..5f0fc60 100644
--- a/ICD.Common.Utils/Extensions/DateTimeExtensions.cs
+++ b/ICD.Common.Utils/Extensions/DateTimeExtensions.cs
@@ -224,6 +224,15 @@ namespace ICD.Common.Utils.Extensions
minutes = MathUtils.Modulus(minutes + extends.Minute, 60);
return new DateTime(extends.Year, extends.Month, extends.Day, extends.Hour, minutes, extends.Second, extends.Millisecond);
}
-
+
+ ///
+ /// Returns the total number of seconds since DateTime.MinValue
+ ///
+ ///
+ ///
+ public static double GetTotalSeconds(this DateTime extends)
+ {
+ return (extends - DateTime.MinValue).TotalSeconds;
+ }
}
}
diff --git a/ICD.Common.Utils/Extensions/EnumerableExtensions.cs b/ICD.Common.Utils/Extensions/EnumerableExtensions.cs
index 10d52b5..5956315 100644
--- a/ICD.Common.Utils/Extensions/EnumerableExtensions.cs
+++ b/ICD.Common.Utils/Extensions/EnumerableExtensions.cs
@@ -1090,6 +1090,22 @@ namespace ICD.Common.Utils.Extensions
///
///
public static T Random([NotNull] this IEnumerable extends)
+ {
+ if (extends == null)
+ throw new ArgumentNullException("extends");
+
+ Random random = new Random(Guid.NewGuid().GetHashCode());
+ return extends.Random(random);
+ }
+
+ ///
+ /// Returns a random item from the given sequence.
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static T Random([NotNull] this IEnumerable extends, [NotNull] Random random)
{
if (extends == null)
throw new ArgumentNullException("extends");
@@ -1099,7 +1115,6 @@ namespace ICD.Common.Utils.Extensions
if (sequence.Count == 0)
throw new InvalidOperationException("Sequence is empty.");
- Random random = new Random(Guid.NewGuid().GetHashCode());
int index = random.Next(0, sequence.Count);
return sequence[index];