Loading ...
Sorry, an error occurred while loading the content.
 

DateTime marshalling, time Zones

Expand Messages
  • Steve Loughran
    So I have a .NET method that returns the current UTC, nothing complex /// /// get the current timestamp in utc format /// ///
    Message 1 of 2 , Oct 3, 2002
      So I have a .NET method that returns the current UTC, nothing complex

      /// <summary>
      /// get the current timestamp in utc format
      /// </summary>
      /// <returns>time set to UTC</returns>
      [WebMethod(Description="return wall time in UTC")]
      public DateTime GetCurrentTime() {
      return DateTime.UtcNow;

      }

      but this goes over the wire with the local TZ, not GMT:
      2002-10-03T15:49:05.0781250-07:00

      So when it comes in at the far end Java picks up the timezone, so a test
      which should always be true:

      public void test7EndpointSoapGetCurrentTime() {
      ...
      java.util.Calendar value;
      value = binding.getCurrentTime();
      java.util.TimeZone tz=value.getTimeZone();
      assertEquals(0,tz.getRawOffset());
      ...
      }

      Bails out : expected:<0> but was:<-28800000>

      This test is now only going to work if the server is in the UK and tests run
      oct 31 to mar 1 (roughly), or on mainland EU with the tests run in summer
      time.

      Oops.

      The problem stems from System.Datetime being a simple counter, with no TZ
      info; someone is assuming that all times are local when sticking them out
      over the wire. Really we need a way of saying what the tz is, maybe even
      datatypes that include tz information the way java.util.Calendar does.

      -Steve
    • John Koropchak
      Steve you are correct, with .NET all times are passed with timezone information so if you get the GMT time in a web method and return the GMT time (say
      Message 2 of 2 , Oct 3, 2002
        Steve you are correct, with .NET all times are passed with timezone
        information so if you get the GMT time in a web method and return the
        GMT time (say 10/3/2002 6:38:58 PM) from the method it will be sent as
        local time 10/3/2002 6:38:58 PM.
        We will be looking into fixing this in future versions.


        _______________________
        This posting is provided "AS IS" with no warranties, and confers no
        rights.

        -----Original Message-----
        From: Steve Loughran [mailto:steve_l@...]
        Sent: Thursday, October 03, 2002 9:13 AM
        To: soapbuilders@yahoogroups.com
        Subject: [soapbuilders] DateTime marshalling, time Zones


        So I have a .NET method that returns the current UTC, nothing complex

        /// <summary>
        /// get the current timestamp in utc format
        /// </summary>
        /// <returns>time set to UTC</returns>
        [WebMethod(Description="return wall time in UTC")]
        public DateTime GetCurrentTime() {
        return DateTime.UtcNow;

        }

        but this goes over the wire with the local TZ, not GMT:
        2002-10-03T15:49:05.0781250-07:00

        So when it comes in at the far end Java picks up the timezone, so a test
        which should always be true:

        public void test7EndpointSoapGetCurrentTime() {
        ...
        java.util.Calendar value;
        value = binding.getCurrentTime();
        java.util.TimeZone tz=value.getTimeZone();
        assertEquals(0,tz.getRawOffset());
        ...
        }

        Bails out : expected:<0> but was:<-28800000>

        This test is now only going to work if the server is in the UK and tests
        run oct 31 to mar 1 (roughly), or on mainland EU with the tests run in
        summer time.

        Oops.

        The problem stems from System.Datetime being a simple counter, with no
        TZ info; someone is assuming that all times are local when sticking them
        out over the wire. Really we need a way of saying what the tz is, maybe
        even datatypes that include tz information the way java.util.Calendar
        does.

        -Steve



        -----------------------------------------------------------------
        This group is a forum for builders of SOAP implementations to discuss
        implementation and interoperability issues. Please stay on-topic.

        To unsubscribe from this group, send an email to:
        soapbuilders-unsubscribe@yahoogroups.com



        Your use of Yahoo! Groups is subject to
        http://docs.yahoo.com/info/terms/
      Your message has been successfully submitted and would be delivered to recipients shortly.