I'm using NodaTime for all of our various time stamping on our raven documents. I'm injecting the IClock
interface using :
IClock clock = SystemClock.Instance;`
The problem is, I'm having a weird issue when I'm serializing a LocalDateTime
into Raven. What's strange is that it's being used elsewhere, but the formatting is coming out fine. I'm running a series of patch commands to update only the SavedDistricts
portion of the document :
new PatchCommandData
{
Key = String.Format("Users/{0}", i),
Patches = (from s in x
select new PatchRequest {Type = PatchCommandType.Add,
Name = "SavedDistricts",
Value = RavenJObject.FromObject(s)
}).ToArray()
}
My object properties :
public class User
{
public string Email { get; set; }
public string Name { get; set; }
public LocalDateTime LastModified { get; set; }
public LocalDateTime CreateDate { get; set; },
public List<District> SavedDistricts { get; set; }
}
public class District
{
public string Id {get; set; }
public LocalDateTime? LastVisited { get; set; }
public LocalDateTime LastModified { get; set; }
}
The way I'm setting the values :
LastModified = _clock.Now.InUtc().LocalDateTime,
LastVisited = LocalDateTime.FromDateTime(userSourceTableEntity.LastVisited.ToLocalTime()),
My document ends up looking like :
{
"Email": "xxxxxx@gmail.com",
"Name": "xxxxxxxxx",
"LastModified": "2013-08-25T08:30:11.0330000",
"CreateDate": "2013-08-25T08:28:25.6130000",
"SavedDistricts": [
{
"Id": "athos",
"LastVisited": {
"ticks": 13774338000000000,
"calendar": "ISO"
},
"LastModified": {
"ticks": 14116967307765180,
"calendar": "ISO"
}
}
]
}
What am I doing wrong here? I have to be missing something in the serialization of these...