Exemplo n.º 1
0
        public static string ToString(TimeSpan timeSpan)
        {
            StringBuilder stringBuilder = new StringBuilder(10);

            stringBuilder.Length = 0;
            if (TimeSpan.Compare(timeSpan, TimeSpan.Zero) < 1)
            {
                stringBuilder.Append('-');
            }
            int value  = 0;
            int value2 = 0;
            int value3 = 0;

            SoapDuration.CarryOver(Math.Abs(timeSpan.Days), out value, out value2, out value3);
            stringBuilder.Append('P');
            stringBuilder.Append(value);
            stringBuilder.Append('Y');
            stringBuilder.Append(value2);
            stringBuilder.Append('M');
            stringBuilder.Append(value3);
            stringBuilder.Append("DT");
            stringBuilder.Append(Math.Abs(timeSpan.Hours));
            stringBuilder.Append('H');
            stringBuilder.Append(Math.Abs(timeSpan.Minutes));
            stringBuilder.Append('M');
            stringBuilder.Append(Math.Abs(timeSpan.Seconds));
            long num  = Math.Abs(timeSpan.Ticks % 864000000000L);
            int  num2 = (int)(num % 10000000L);

            if (num2 != 0)
            {
                string value4 = ParseNumbers.IntToString(num2, 10, 7, '0', 0);
                stringBuilder.Append('.');
                stringBuilder.Append(value4);
            }
            stringBuilder.Append('S');
            return(stringBuilder.ToString());
        }
Exemplo n.º 2
0
        public static string ToString(TimeSpan timeSpan)
        {
            StringBuilder stringBuilder = new StringBuilder(10);

            stringBuilder.Length = 0;
            if (TimeSpan.Compare(timeSpan, TimeSpan.Zero) < 1)
            {
                stringBuilder.Append('-');
            }
            int years  = 0;
            int months = 0;
            int days   = 0;

            SoapDuration.CarryOver(Math.Abs(timeSpan.Days), out years, out months, out days);
            stringBuilder.Append('P');
            stringBuilder.Append(years);
            stringBuilder.Append('Y');
            stringBuilder.Append(months);
            stringBuilder.Append('M');
            stringBuilder.Append(days);
            stringBuilder.Append("DT");
            stringBuilder.Append(Math.Abs(timeSpan.Hours));
            stringBuilder.Append('H');
            stringBuilder.Append(Math.Abs(timeSpan.Minutes));
            stringBuilder.Append('M');
            stringBuilder.Append(Math.Abs(timeSpan.Seconds));
            int l = (int)(Math.Abs(timeSpan.Ticks % 864000000000L) % 10000000L);

            if (l != 0)
            {
                string @string = ParseNumbers.IntToString(l, 10, 7, '0', 0);
                stringBuilder.Append('.');
                stringBuilder.Append(@string);
            }
            stringBuilder.Append('S');
            return(stringBuilder.ToString());
        }