-
Notifications
You must be signed in to change notification settings - Fork 0
/
Util.cs
36 lines (32 loc) · 998 Bytes
/
Util.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
using System;
namespace Us.FolkV3.Api
{
internal static class Util
{
public static T RequireNonNull<T>(T value, string name)
{
if (value == null)
{
throw new ArgumentNullException($"{name} must not be null");
}
return value;
}
public static int HashCode(params Object[] elements)
{
if (elements == null)
{
return 0;
}
int result = 1;
foreach (var element in elements)
{
result = 31 * result + (element == null ? 0 : element.GetHashCode());
}
return result;
}
public static long CurrentTimeMillis() =>
new DateTimeOffset(DateTime.Now).ToUnixTimeMilliseconds();
public static string ToISOString(this DateTime dateTime) =>
dateTime.ToString("s", System.Globalization.CultureInfo.InvariantCulture);
}
}