Skip to content

Instantly share code, notes, and snippets.

@shiftkey
Last active December 11, 2015 12:18
Show Gist options
  • Save shiftkey/4599342 to your computer and use it in GitHub Desktop.
Save shiftkey/4599342 to your computer and use it in GitHub Desktop.
Repro: DateTimeOffset support missing in ServiceStack.OrmLite.SqlServer (supported in SQL Server 2008+)
using System;
using NUnit.Framework;
using ServiceStack.OrmLite.SqlServer;
namespace ServiceStack.OrmLite.SqlServerTests
{
[TestFixture]
public class DateTimeOffsetTests
{
// NOTE: ISO 8601 says no whitespace between time value and timezone parameter
// SQL Server happily accepts this format
[Test]
public void DateTimeOffset_Is_Not_Formatted_As_Per_ISO_8601()
{
// arrange
var subject = new SqlServerOrmLiteDialectProvider();
var now = DateTimeOffset.Now;
var expected = string.Format("'{0}'", now.ToString("yyyy-MM-dd HH:mm:ss.fff zzz"));
// act
var output = subject.GetQuotedValue(now, typeof(DateTimeOffset));
Assert.AreEqual(expected, output);
}
}
}
Expected string length 32 but was 30. Strings differ at index 2.
Expected: "'2013-01-23 09:29:42.898 +11:00'"
But was: "'23/01/2013 9:29:42 AM +11:00'"
-------------^
@shiftkey
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment