mirror of
https://github.com/Tyrrrz/DiscordChatExporter.git
synced 2026-02-03 00:29:20 +00:00
17 lines
544 B
C#
17 lines
544 B
C#
using System;
|
|
using System.Globalization;
|
|
|
|
namespace DiscordChatExporter.Domain.Internal
|
|
{
|
|
internal static class DateExtensions
|
|
{
|
|
public static string ToSnowflake(this DateTimeOffset dateTime)
|
|
{
|
|
var value = ((ulong) dateTime.ToUnixTimeMilliseconds() - 1420070400000UL) << 22;
|
|
return value.ToString();
|
|
}
|
|
|
|
public static string ToLocalString(this DateTimeOffset dateTime, string format) =>
|
|
dateTime.ToLocalTime().ToString(format, CultureInfo.InvariantCulture);
|
|
}
|
|
} |