mirror of
https://github.com/Tyrrrz/DiscordChatExporter.git
synced 2025-05-22 10:55:15 -04:00
Re-add IComparable<T>
to Snowflake
This commit is contained in:
parent
7c88a21543
commit
d8de3bf779
1 changed files with 9 additions and 1 deletions
|
@ -5,7 +5,7 @@ using System.Text.RegularExpressions;
|
||||||
|
|
||||||
namespace DiscordChatExporter.Core.Discord
|
namespace DiscordChatExporter.Core.Discord
|
||||||
{
|
{
|
||||||
public readonly record struct Snowflake(ulong Value)
|
public readonly partial record struct Snowflake(ulong Value)
|
||||||
{
|
{
|
||||||
public DateTimeOffset ToDate() => DateTimeOffset.FromUnixTimeMilliseconds(
|
public DateTimeOffset ToDate() => DateTimeOffset.FromUnixTimeMilliseconds(
|
||||||
(long)((Value >> 22) + 1420070400000UL)
|
(long)((Value >> 22) + 1420070400000UL)
|
||||||
|
@ -13,7 +13,10 @@ namespace DiscordChatExporter.Core.Discord
|
||||||
|
|
||||||
[ExcludeFromCodeCoverage]
|
[ExcludeFromCodeCoverage]
|
||||||
public override string ToString() => Value.ToString(CultureInfo.InvariantCulture);
|
public override string ToString() => Value.ToString(CultureInfo.InvariantCulture);
|
||||||
|
}
|
||||||
|
|
||||||
|
public partial record struct Snowflake
|
||||||
|
{
|
||||||
public static Snowflake Zero { get; } = new(0);
|
public static Snowflake Zero { get; } = new(0);
|
||||||
|
|
||||||
public static Snowflake FromDate(DateTimeOffset date) => new(
|
public static Snowflake FromDate(DateTimeOffset date) => new(
|
||||||
|
@ -45,4 +48,9 @@ namespace DiscordChatExporter.Core.Discord
|
||||||
|
|
||||||
public static Snowflake Parse(string str) => Parse(str, null);
|
public static Snowflake Parse(string str) => Parse(str, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public partial record struct Snowflake : IComparable<Snowflake>
|
||||||
|
{
|
||||||
|
public int CompareTo(Snowflake other) => Value.CompareTo(other.Value);
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue