[CSHARP-173] On mono, BsonDateTime.Value does not respect timezones. Created: 25/Feb/11  Updated: 02/Apr/15  Resolved: 11/Mar/11

Status: Closed
Project: C# Driver
Component/s: None
Affects Version/s: 0.11
Fix Version/s: 1.0

Type: Bug Priority: Major - P3
Reporter: Justin Dearing Assignee: Robert Stam
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Ubuntu Mono JIT compiler version 2.6.7 (Debian 2.6.7-3ubuntu1



 Description   

I get the following failed test:
MongoDB.BsonUnitTests.BsonTypeMapperTests.TestMapString:
Expected: 2010-01-02 00:00:00.000
But was: 2010-01-02 05:00:00.000

This fixes the test on mono (run through nunit-console). Its probably not the right answer:

zippy@maya-gwapa:~/src/mongo-csharp$ git diff
diff --git a/BsonUnitTests/ObjectModel/BsonTypeMapperTests.cs b/BsonUnitTests/ObjectModel/BsonTypeMapperTests.cs
index c5f0a28..a2133b5 100644
— a/BsonUnitTests/ObjectModel/BsonTypeMapperTests.cs
+++ b/BsonUnitTests/ObjectModel/BsonTypeMapperTests.cs
@@ -457,7 +457,7 @@ namespace MongoDB.BsonUnitTests {
var bsonBoolean = (BsonBoolean) BsonTypeMapper.MapToBsonValue("1", BsonType.Boolean);
Assert.AreEqual(true, bsonBoolean.Value);
var bsonDateTime = (BsonDateTime) BsonTypeMapper.MapToBsonValue("2010-01-02", BsonType.DateTime);

  • Assert.AreEqual(new DateTime(2010, 1, 2), bsonDateTime.Value);
    + Assert.AreEqual(new DateTime(2010, 1, 2), bsonDateTime.Value.ToLocalTime());
    var bsonDouble = (BsonDouble) BsonTypeMapper.MapToBsonValue("1.2", BsonType.Double);
    Assert.AreEqual(1.2, bsonDouble.Value);
    var bsonInt32 = (BsonInt32) BsonTypeMapper.MapToBsonValue("1", BsonType.Int32);


 Comments   
Comment by Robert Stam [ 11/Mar/11 ]

Fixed.

Generated at Wed Feb 07 21:36:01 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.