* SoapAnyUri.cs, SoapBase64Binary.cs, SoapDate.cs, SoapDateTime.cs
[mono.git] / mcs / class / corlib / System.Runtime.Remoting.Metadata.W3cXsd2001 / SoapDay.cs
1 //
2 // System.Runtime.Remoting.Metadata.W3cXsd2001.SoapDay
3 //
4 // Authors:
5 //      Martin Willemoes Hansen (mwh@sysrq.dk)
6 //      Lluis Sanchez Gual (lluis@ximian.com)
7 //
8 // (C) 2003 Martin Willemoes Hansen
9 //
10
11 using System;
12 using System.Globalization;
13
14 namespace System.Runtime.Remoting.Metadata.W3cXsd2001 
15 {
16         [Serializable]
17         public sealed class SoapDay : ISoapXsd
18         {
19                 static string[] _datetimeFormats = new string[]
20                 {
21                         "---dd",
22                         "---ddzzz"
23                 };
24                 
25                 DateTime _value;
26                 
27                 public SoapDay ()
28                 {
29                 }
30                 
31                 public SoapDay (DateTime value)
32                 {
33                         _value = value;
34                 }
35                 
36                 public DateTime Value {
37                         get { return _value; } 
38                         set { _value = value; }
39                 }
40
41                 public static string XsdType {
42                         get { return "gDay"; }
43                 }
44
45                 public string GetXsdType()
46                 {
47                         return XsdType;
48                 }
49                 
50                 public static SoapDay Parse (string value)
51                 {
52                         DateTime d = DateTime.ParseExact (value, _datetimeFormats, null, DateTimeStyles.None);
53                         return new SoapDay (d);
54                 }
55                 
56                 public override string ToString()
57                 {
58                         return _value.ToString("---dd", CultureInfo.InvariantCulture);
59                 }
60         }
61 }