diff --git a/SweetLib/Utils/SweetUtils.cs b/SweetLib/Utils/SweetUtils.cs index 57e2a2a..53e6b3a 100644 --- a/SweetLib/Utils/SweetUtils.cs +++ b/SweetLib/Utils/SweetUtils.cs @@ -34,10 +34,20 @@ namespace SweetLib.Utils { var invalidChars = System.IO.Path.GetInvalidFileNameChars(); - if(invalidChars.Contains(replaceChar)) + if (invalidChars.Contains(replaceChar)) throw new IOException($"Replace character {replaceChar} is an invalid file name character."); return invalidChars.Aggregate(fileName, (current, c) => current.Replace(c, replaceChar)); } + + /// + /// Converts a into an Unix timestamp. + /// + /// to convert into Unix timestamp. + /// Converted Unix timestamp + public static double DateTimeToUnixTimeStamp(DateTime date) + { + return date.Subtract(new DateTime(1970, 1, 1)).TotalSeconds; + } } }