The other thing is the way the serializer handles DateTimes. Even if the
date is UTC, it will put the TZ on the wire like:
<dateTime>2005-04-06T05:12:10.5468750-04:00</dateTime> (note Eastern TZ).
This is not correct as it should be Zulu time with no timezone. Not sure
how that will be handled in all cases at different timezones. Therefore,
when I pass DateTime, I always work in Zulu time and pass the date myself as
a string. That way I always know it is a true UTC and I can convert to
local time if needed at the client side. Use these two methods for the
conversions. ToUTCDateTimeString at the server and FromUTCDateTimeString at
the client.
/// <summary>
/// Returns string formatted in Zulu (UTC) time. value must be UTC
DateTime.
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
public static string ToUTCDateTimeString(DateTime value)
{
// Date expected to be UTC date already.
// e.g 2003-10-26T14:33:41.1234567Z
return value.ToString("yyyy-MM-ddTHH:mm:ssZ",
CultureInfo.InvariantCulture);
}
/// <summary>
/// Parses the UTC formatted string, returning DateTime in UTC.
/// Use ToLocalTime() on the result if you want to convert to local time.
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
public static DateTime FromUTCDateTimeString(string value)
{
return DateTime.Parse(value, CultureInfo.InvariantCulture,
DateTimeStyles.AdjustToUniversal);
}
--
William Stacey, MVP
http://mvp.support.microsoft.com
<pi****@gmail.com> wrote in message
news:11*********************@f14g2000cwb.googlegro ups.com...
not if the client & server are in different time zones.
client code:
Console.WriteLine (service.GetTime ().ToString ("s"));