added DateTimeToUnixTimestamp helper

This commit is contained in:
Serraniel 2017-05-20 10:17:59 +02:00
parent 1116e85cd7
commit 01b4c28054

View file

@ -39,5 +39,15 @@ namespace SweetLib.Utils
return invalidChars.Aggregate(fileName, (current, c) => current.Replace(c, replaceChar)); return invalidChars.Aggregate(fileName, (current, c) => current.Replace(c, replaceChar));
} }
/// <summary>
/// Converts a <see cref="DateTime"/> into an Unix timestamp.
/// </summary>
/// <param name="date"><see cref="DateTime"/> to convert into Unix timestamp.</param>
/// <returns>Converted Unix timestamp</returns>
public static double DateTimeToUnixTimeStamp(DateTime date)
{
return date.Subtract(new DateTime(1970, 1, 1)).TotalSeconds;
}
} }
} }