You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

SnowflakeUtils.cs 391 B

123456789101112
  1. using System;
  2. namespace Discord
  3. {
  4. public static class SnowflakeUtils
  5. {
  6. public static DateTimeOffset FromSnowflake(ulong value)
  7. => DateTimeOffset.FromUnixTimeMilliseconds((long)((value >> 22) + 1420070400000UL));
  8. public static ulong ToSnowflake(DateTimeOffset value)
  9. => ((ulong)value.ToUnixTimeMilliseconds() - 1420070400000UL) << 22;
  10. }
  11. }