diff --git a/.vscode/settings.json b/.vscode/settings.json
new file mode 100644
index 0000000..3bde2e5
--- /dev/null
+++ b/.vscode/settings.json
@@ -0,0 +1,3 @@
+{
+ "dotnet.defaultSolution": "NUlid.sln"
+}
diff --git a/NUlid/DateTimeExtensions.cs b/NUlid/DateTimeExtensions.cs
new file mode 100644
index 0000000..b3474b8
--- /dev/null
+++ b/NUlid/DateTimeExtensions.cs
@@ -0,0 +1,33 @@
+using System;
+
+namespace NUlid;
+
+///
+/// Extension methods for and to create s.
+///
+public static class DateTimeExtensions
+{
+ ///
+ /// Returns a new based on the current value.
+ ///
+ /// date time offset to base new ULID upon
+ /// A new
+ public static Ulid NewUlid(this DateTimeOffset dateTimeOffset)
+ => Ulid.NewUlid(dateTimeOffset);
+
+ ///
+ /// Returns the minimum based on the current value.
+ ///
+ /// date time offset to base new ULID upon
+ /// A new
+ public static Ulid MinUlid(this DateTimeOffset dateTimeOffset)
+ => Ulid.MinAt(dateTimeOffset);
+
+ ///
+ /// Returns the maximum based on the current value.
+ ///
+ /// date time offset to base new ULID upon
+ /// A new
+ public static Ulid MaxUlid(this DateTimeOffset dateTimeOffset)
+ => Ulid.MaxAt(dateTimeOffset);
+}
diff --git a/NUlid/NUlid.csproj b/NUlid/NUlid.csproj
index d3babf9..70dab33 100644
--- a/NUlid/NUlid.csproj
+++ b/NUlid/NUlid.csproj
@@ -1,50 +1,50 @@
-
- netstandard2.0;net6.0
- RobIII
- Devcorner.nl
- NUlid
- true
- NUlid
- (C) 2016 - 2025 Devcorner.nl
- enable
- MIT
- https://github.com/RobThree/NUlid
- Universally Unique Lexicographically Sortable Identifier;ULID;UUID;GUID
- A .Net ULID implementation
- latest
- logo.png
- True
- bin\Release\nulid.xml
- Debug;Release
- true
- latest
- README.md
- https://github.com/RobThree/NUlid
- git
-
+
+ netstandard2.0;net6.0
+ RobIII
+ Devcorner.nl
+ NUlid
+ true
+ NUlid
+ (C) 2016 - 2025 Devcorner.nl
+ enable
+ MIT
+ https://github.com/RobThree/NUlid
+ Universally Unique Lexicographically Sortable Identifier;ULID;UUID;GUID
+ A .Net ULID implementation
+ latest
+ logo.png
+ True
+ bin\Release\nulid.xml
+ Debug;Release
+ true
+ latest
+ README.md
+ https://github.com/RobThree/NUlid
+ git
+
-
- TRACE;RELEASE
-
+
+ TRACE;RELEASE
+
-
- bin\release\NUlid.xml
-
+
+ bin\release\NUlid.xml
+
-
-
-
+
+
+
-
-
- True
-
-
-
- True
- \
-
-
-
\ No newline at end of file
+
+
+ True
+
+
+
+ True
+ \
+
+
+
diff --git a/NUlid/Ulid.cs b/NUlid/Ulid.cs
index e42b101..41f9c5a 100644
--- a/NUlid/Ulid.cs
+++ b/NUlid/Ulid.cs
@@ -1,12 +1,13 @@
-using NUlid.Rng;
-using System;
+using System;
+using System.Buffers.Binary;
using System.ComponentModel;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
+using NUlid.Rng;
+
#if NET6_0_OR_GREATER
-using System.Buffers.Binary;
using System.Runtime.CompilerServices;
using System.Runtime.Intrinsics;
#endif
@@ -53,12 +54,12 @@ public struct Ulid : IEquatable, IComparable, IComparable, ISerializ
///
/// Represents the smallest possible value of . This field is read-only.
///
- public static readonly Ulid MinValue = new(_epoch, [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]);
+ public static readonly Ulid MinValue = MinAt(_epoch);
///
/// Represents the largest possible value of . This field is read-only.
///
- public static readonly Ulid MaxValue = new(DateTimeOffset.MaxValue, [255, 255, 255, 255, 255, 255, 255, 255, 255, 255]);
+ public static readonly Ulid MaxValue = MaxAt(DateTimeOffset.MaxValue);
///
/// A read-only instance of the structure whose value is all zeros.
@@ -104,6 +105,22 @@ public static Ulid NewUlid(DateTimeOffset time)
public static Ulid NewUlid(IUlidRng rng)
=> NewUlid(DateTimeOffset.UtcNow, rng);
+ ///
+ /// Creates and returns a new that is the minimum possible value for the specified time.
+ ///
+ /// The to use for the time-part of the .
+ /// Returns a new .
+ public static Ulid MinAt(DateTimeOffset time)
+ => new(time, new byte[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 });
+
+ ///
+ /// Creates and returns a new that is the maximum possible value for the specified time.
+ ///
+ /// The to use for the time-part of the .
+ /// Returns a new .
+ public static Ulid MaxAt(DateTimeOffset time)
+ => new(time, new byte[] { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 });
+
///
/// Creates and returns a new based on the specified time and using the specified RNG.
///
@@ -868,4 +885,4 @@ public readonly string ToString(string? format, IFormatProvider? formatProvider)
//public static Ulid FromString(string ulid) => new Ulid(ulid);
//public static implicit operator Ulid(string ulid) => FromString(ulid);
//public static implicit operator string(Ulid ulid) => ulid.ToString();
-}
\ No newline at end of file
+}
diff --git a/global.json b/global.json
new file mode 100644
index 0000000..788c9b7
--- /dev/null
+++ b/global.json
@@ -0,0 +1,7 @@
+{
+ "sdk": {
+ "version": "9.0.100",
+ "allowPrerelease": false,
+ "rollForward": "latestMinor"
+ }
+}