Returns the UTC DateTime the guid was created. Will not work with ToSqlGuid().
Syntax
Visual Basic (Declaration) | |
---|
Public Function ToDateTimeUtc() As Date |
Example
Library/Library.Test/TestDbGuid.cs
C# | Copy Code |
---|
// Note: DateTime precision is +/- 1ms
DateTime start = DateTime.UtcNow.AddMilliseconds(-1);
DbGuid test = DbGuid.NewGuid();
Assert.IsTrue(test.ToDateTimeUtc() > start, "expected {0} > {1}", test.ToDateTimeUtc(), start);
DateTime now = DateTime.UtcNow.AddMilliseconds(1);
Assert.IsTrue(test.ToDateTimeUtc() <= now, "expected {0} <= {1}", test.ToDateTimeUtc(), now); |
VB.NET | Copy Code |
---|
' Note: DateTime precision is +/- 1ms
Dim start As DateTime = DateTime.UtcNow.AddMilliseconds(-1)
Dim test As DbGuid = DbGuid.NewGuid()
Assert.IsTrue(test.ToDateTimeUtc() > start, "expected {0} > {1}", test.ToDateTimeUtc(), start)
Dim now As DateTime = DateTime.UtcNow.AddMilliseconds(1)
Assert.IsTrue(test.ToDateTimeUtc() <= now, "expected {0} <= {1}", test.ToDateTimeUtc(), now) |
Requirements
Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7
See Also