forked from Inumedia/SlackAPI
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExtensions.cs
More file actions
24 lines (23 loc) · 758 Bytes
/
Copy pathExtensions.cs
File metadata and controls
24 lines (23 loc) · 758 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SlackAPI
{
public static class Extensions
{
/// <summary>
/// Converts to a propert JavaScript timestamp interpretted by Slack. Also handles converting to UTC.
/// </summary>
/// <param name="that"></param>
/// <returns></returns>
public static string ToProperTimeStamp(this DateTime that, bool toUTC = true)
{
if (toUTC)
return that.ToUniversalTime().Subtract(new DateTime(1970, 1, 1)).TotalSeconds.ToString();
else
return that.Subtract(new DateTime(1970, 1, 1)).TotalSeconds.ToString();
}
}
}