public void FromSnowflake() { // snowflake from a userid var id = 163184946742034432u; Assert.Equal(new DateTime(2016, 3, 26, 7, 18, 43), SnowflakeUtils.FromSnowflake(id).UtcDateTime, TimeSpan.FromSeconds(1)); }
// Bulk Delete public static void YoungerThanTwoWeeks(ulong[] collection, string name) { var minimum = SnowflakeUtils.ToSnowflake(DateTimeOffset.UtcNow.Subtract(TimeSpan.FromDays(14))); for (var i = 0; i < collection.Length; i++) { if (collection[i] <= minimum) { throw new ArgumentOutOfRangeException(name, "Messages must be younger than two weeks old."); } } }
public void ToSnowflake() { // most significant digits should match, but least significant digits cannot be determined from here Assert.Equal(163184946184192000u, SnowflakeUtils.ToSnowflake(new DateTimeOffset(2016, 3, 26, 7, 18, 43, TimeSpan.Zero))); }