-
Type: Bug
-
Resolution: Done
-
Priority: Minor - P4
-
None
-
Affects Version/s: 2.7.0
-
Component/s: Serialization
-
Labels:None
-
Environment:Cosmos Db
The string returned by my custom serializer, which is overriding how datetime strings are formatted is "2018-07-18T14:35:27.7108283+02:00". However in my database the stored value is "2018-07-18T12:35:27.7108283+00:00".
My code:
BsonSerializer.RegisterSerializer(new DateTimeOffsetSerializer(BsonType.Document)); public class MyDateTimeOffsetSerializer : StructSerializerBase<DateTimeOffset> { public override void Serialize(BsonSerializationContext context, BsonSerializationArgs args, DateTimeOffset value) { IBsonWriter writer = context.Writer; writer.WriteString(ToString(value)); } public static string ToString(DateTimeOffset value) { var x = value.ToString("O"); return x; // returns string like "2018-07-18T14:35:27.7108283+02:00" } }
The serializer is registered right before I Insert the document. What is happening to the value after I've serialized it and how can I change it?