internal static DateTime ToDateTime(string s, XmlDateTimeSerializationMode dateTimeOption) { XsdDateTime xsdDateTime = new XsdDateTime(s, XsdDateTimeFlags.AllXsd); DateTime dt = xsdDateTime; switch (dateTimeOption) { case XmlDateTimeSerializationMode.Local: dt = SwitchToLocalTime(dt); break; case XmlDateTimeSerializationMode.Utc: dt = SwitchToUtcTime(dt); break; case XmlDateTimeSerializationMode.Unspecified: dt = new DateTime(dt.Ticks, DateTimeKind.Unspecified); break; case XmlDateTimeSerializationMode.RoundtripKind: break; default: throw new ArgumentException( //TODO: string.Format( "The '{0}' value for the 'dateTimeOption' parameter is not an allowed value for the 'XmlDateTimeSerializationMode' enumeration.", "dateTimeOption")); } return(dt); }
internal static string ToString(DateTime value, XmlDateTimeSerializationMode dateTimeOption) { switch (dateTimeOption) { case XmlDateTimeSerializationMode.Local: value = SwitchToLocalTime(value); break; case XmlDateTimeSerializationMode.Utc: value = SwitchToUtcTime(value); break; case XmlDateTimeSerializationMode.Unspecified: value = new DateTime(value.Ticks, DateTimeKind.Unspecified); break; case XmlDateTimeSerializationMode.RoundtripKind: break; default: throw new ArgumentException( //TODO: string.Format( "The '{0}' value for the 'dateTimeOption' parameter is not an allowed value for the 'XmlDateTimeSerializationMode' enumeration.", "dateTimeOption")); } XsdDateTime xsdDateTime = new XsdDateTime(value, XsdDateTimeFlags.DateTime); return(xsdDateTime.ToString()); }