Based on the ideas Dino sent me, I managed to find out a working solution to my
problem. I also realised that it's possible to keep xsd:dateTime in my schema and to
use it in a Web Service. Only drawback is that the wsdl can't be autogenerated.
Here's roughly what I came up with:
public class Approval {
public string Manager;
public int ProjectId;
public string Location;
public string ApprovedAt;
[XmlIgnore]
public DateTime LocalApprovedAt {
get {
return DateTime.Parse(ApprovedAt);
}
set {
ApprovedAt = value.ToString("yyyy-MM-ddTHH:mm:ss");
}
}
}
public static void TestApproval() {
Approval obj = new Approval();
obj.Manager = "Smith";
obj.ProjectId = 1234;
obj.Location = "Pleasantville";
obj.LocalApprovedAt = DateTime.Parse("2002-02-28 13:48:00");
XmlSerializer serializer = new XmlSerializer(typeof(Approval));
StreamWriter writer = new StreamWriter("obj.xml");
serializer.Serialize(writer, obj);
writer.Close();
}
/Bjorn
"Dino Chiesa [Microsoft]" wrote:
[color=blue]
> This example shows some of the possibilities.
>
http://www.winisp.net/cheeso/srcview...le=DateTime.cs
>
> -D
>
> "BjörnHolmberg" <bjRemovethiSorn.holmberg@suliteAndthiSlma.com> wrote in
> message news:411345C6.4AFD1A22@suliteAndthiSlma.com...[color=green]
> > Hi everyone!
> >
> > In the following code we get a UTC offset in xml. Since I want my WAP[/color]
> users in[color=green]
> > UTC+02:00 to see data on a server in some US time zone, a lot of confusion[/color]
> will[color=green]
> > be created from this behavior. Either I use .NET logic on the server and[/color]
> get[color=green]
> > server local time or I create xhtml pages directly from serialized[/color]
> objects.[color=green]
> > Eitherway I'll have to write my own logic to take care of utc offset. Is[/color]
> it[color=green]
> > possible to override XmlSerializer so what my local desktop user send to[/color]
> the[color=green]
> > webservice is saved on the server without utc offset? That way, the time[/color]
> that is[color=green]
> >
> > local to my users will be saved on the server. I guess it's kind of hard[/color]
> to[color=green]
> > tweak ASP.NET WebService infrastructure into this. On the other hand it[/color]
> feels[color=green]
> > like bad manners to change my xsd:dateTime values to xsd:string because of[/color]
> what[color=green]
> > i discover about .NET. /Regards Bjorn
> >
> > public class SomeDates {
> > public DateTime Summer;
> > public DateTime Winter;
> > }
> >
> > public static void TestSomeDates() {
> > SomeDates obj = new SomeDates();
> > obj.Winter = DateTime.Parse("2003-12-22 12:32:45");
> > obj.Summer = DateTime.Parse("2004-08-05 18:45:21");
> > XmlSerializer serializer = new XmlSerializer(typeof(SomeDates));
> > StreamWriter writer = new StreamWriter("obj.xml");
> > serializer.Serialize(writer, obj);
> > writer.Close();
> > }
> >
> >
> >
> >
> >[/color][/color]