DateTime serialization and involuntary TimeZone adjustments, saga continues

Discussion in 'ASP .Net Web Services' started by sonic, Oct 9, 2006.

  1. sonic

    sonic Guest

    Hello,

    I am having an issue that should affect anyone that is trying to pass
    DateTime object to client javascript. I've been having this issue for
    weeks and even though found some workarounds ( mentioned below ) I am
    still not satisfied with this issue as "resolved".

    I am currently in final stages of deploying a fairly big atlas
    solution. I've been very pleased with the experience developing in
    asp.net 2.0 and atlas accept for the datetime serialization, and
    javascriptobjectserializer to a lesser extent.

    datetime properties are always adjusted with a browser time zone
    whenever atlas script manager is used to call webservices directly, or
    javascriptobjectserializer is used.

    i started using JSON ( instead of javascriptobjectserializer) because
    it allows for object converters to be supplied so that serialization of
    certain types of properties can be fully controlled.
    javascriptobjectserializer also appears to serialize enums incorrectly
    ( as ints instead of strings ) so json was helpful in that regard for
    me.

    atlas ajax:
    calling webservices directly from javascript using atlas script manager
    control will automatically adjust all datetimes even if the server and
    browser are on the same machine (and yes my time zone is set
    correctly),

    the only remedy i found so far is that converting datetime
    ..ToUniversalTime() on the server can be helpful in stopping timezone
    adjustments. but this will be a big pain when using custom objects and
    2 way communication.

    Brad Abrams posted a way to ignore Time in DateTime serialization, and
    that is by adding [XmlAttribute(DataType = "date")] to the property
    definition. this will work between web and app tiers, but appears to be
    ignored by atlas serialization as well. (of course this method is only
    useful when only the Date portion is relevant and you dont want the
    adjusted timezone to kick the date back or forward a day)

    i wish there was a way to set IIS to stop adjusting timezone for
    browsers.
    Perhaps I am missing something more obvious here and i will keep at it
    until its all clear
    sonic, Oct 9, 2006
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Christos TZOTZIOY Georgiou
    Replies:
    3
    Views:
    704
    Christos TZOTZIOY Georgiou
    Sep 13, 2003
  2. Ethan Furman

    the unicode saga continues...

    Ethan Furman, Nov 14, 2009, in forum: Python
    Replies:
    2
    Views:
    476
    Martin v. Löwis
    Nov 14, 2009
  3. Alex Hall

    py2exe saga continues...

    Alex Hall, Apr 16, 2010, in forum: Python
    Replies:
    1
    Views:
    241
    alex23
    Apr 16, 2010
  4. Ami
    Replies:
    5
    Views:
    279
  5. Justin Voelker
    Replies:
    2
    Views:
    263
    Dr J R Stockton
    Dec 2, 2008
Loading...

Share This Page