From e640e52f198211e03d3dfd16cdf468ba31957516 Mon Sep 17 00:00:00 2001 From: nugroho Date: Wed, 25 Jun 2025 02:13:42 +0700 Subject: [PATCH] allows generator to use supplied DateTime --- Commons.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Commons.cs b/Commons.cs index 86c1903..4be7b2d 100644 --- a/Commons.cs +++ b/Commons.cs @@ -101,10 +101,10 @@ internal static class Commons } } - internal static string GenerateUuidV7() + internal static string GenerateUuidV7(DateTime? BaseTime = null) { Span uuidBytes = stackalloc byte[16]; - long time = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(); + long time = (BaseTime is null ? DateTimeOffset.UtcNow : new DateTimeOffset((DateTime)BaseTime)).ToUnixTimeMilliseconds(); RandomNumberGenerator.Fill(uuidBytes[7..]); if (BitConverter.IsLittleEndian) {