Closed miksovic closed 13 years ago
this is probably a timezone issue: when you create a DateTime
object, without specifying its Kind
, it is set to Unspecified
, which looks like Local
but behaves like UTC
. when agnos packs a DateTime
object, it converts the object to UTC. also, when you read back (unpack) a DateTime
object, you get it in UTC as well. long story short, it's best to always explicitly specify the Kind
, either Local
or UTC
. next, in order to convert an agnos-returned DateTime object to local time, use .ToLocalTime()
, e.g. DateTime d = some_agnos_func_that_returns_a_datetime().ToLocalTime()
i don't think there's anything wrong with the way agnos packs/unpacks DateTime
objects. see the code
@miksovic, maybe i was too trigger-happy on the "close issue" button. did my suggestion solve the problem?
edit: by the way, i just noticed you're from new zealand, and you guys are UTC+12, which seems to explain your deviation :)
thanks, -tomer
Yes it did. Cheers.. Maybe changing the Unspecified kind to UTC before packing would be more transparent for people who don't know how it works internally? You'd still have the option to set it Local before sending and get the time in UTC on the remote side of the RPC call. I suppose most of the time someone who didn't specify the kind (like me;-) would like to get the same datetime value as was sent.
DateTime has -12 hours time difference when passed as a function argument from client to server (C#/C#)