mirror of
https://github.com/Tyrrrz/DiscordChatExporter.git
synced 2026-03-31 02:39:06 +00:00
Improve performance (#162)
This commit is contained in:
18
DiscordChatExporter.Core.Services/Internal/Extensions.cs
Normal file
18
DiscordChatExporter.Core.Services/Internal/Extensions.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
|
||||
namespace DiscordChatExporter.Core.Services.Internal
|
||||
{
|
||||
internal static class Extensions
|
||||
{
|
||||
public static string ToSnowflake(this DateTime dateTime)
|
||||
{
|
||||
const long epoch = 62135596800000;
|
||||
var unixTime = dateTime.ToUniversalTime().Ticks / TimeSpan.TicksPerMillisecond - epoch;
|
||||
var value = ((ulong) unixTime - 1420070400000UL) << 22;
|
||||
return value.ToString();
|
||||
}
|
||||
|
||||
public static Color ResetAlpha(this Color color) => Color.FromArgb(1, color);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user