tomerfiliba / agnos

Agnos - The Agnostic RPC Framework
http://agnos.sourceforge.net
Other
14 stars 7 forks source link

DateTime -12 hours #43

Closed miksovic closed 13 years ago

miksovic commented 13 years ago

DateTime has -12 hours time difference when passed as a function argument from client to server (C#/C#)

tomerfiliba commented 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

tomerfiliba commented 13 years ago

@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

miksovic commented 13 years ago

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.