Beispiel #1
0
        ///<include file='doc\XmlConvert.uex' path='docs/doc[@for="XmlConvert.ToString14"]/*' />
        /// <devdoc>
        ///    <para>[To be supplied.]</para>
        /// </devdoc>
        public 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(SR.Format(SR.Sch_InvalidDateTimeOption, dateTimeOption, "dateTimeOption"));
            }
            XsdDateTime xsdDateTime = new XsdDateTime(value, XsdDateTimeFlags.DateTime);

            return(xsdDateTime.ToString());
        }
Beispiel #2
0
        public static string ToString(DateTimeOffset value)
        {
            XsdDateTime xsdDateTime = new XsdDateTime(value);

            return(xsdDateTime.ToString());
        }