CSharpTest.Net
ToDateTimeUtc Method
See Also  Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Data Namespace > DbGuid Structure : ToDateTimeUtc Method

Glossary Item Box

Returns the UTC DateTime the guid was created. Will not work with ToSqlGuid().

Syntax

Visual Basic (Declaration) 
Public Function ToDateTimeUtc() As Date
C# 
public DateTime ToDateTimeUtc()

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.NETCopy 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

Generated with Document! X 2011 by Innovasys