added DateTimeToUnixTimestamp helper
This commit is contained in:
parent
1116e85cd7
commit
01b4c28054
|
@ -39,5 +39,15 @@ namespace SweetLib.Utils
|
|||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue