CopyIntToCharArray() private static method

private static CopyIntToCharArray ( char chars, int start, int value, int digits ) : void
chars char
start int
value int
digits int
return void
        internal static int WriteDefaultIsoDate(char[] chars, int start, DateTime dt)
        {
            int num = 19;
            int value;
            int value2;
            int value3;

            DateTimeUtils.GetDateValues(dt, out value, out value2, out value3);
            DateTimeUtils.CopyIntToCharArray(chars, start, value, 4);
            chars[start + 4] = '-';
            DateTimeUtils.CopyIntToCharArray(chars, start + 5, value2, 2);
            chars[start + 7] = '-';
            DateTimeUtils.CopyIntToCharArray(chars, start + 8, value3, 2);
            chars[start + 10] = 'T';
            DateTimeUtils.CopyIntToCharArray(chars, start + 11, dt.Hour, 2);
            chars[start + 13] = ':';
            DateTimeUtils.CopyIntToCharArray(chars, start + 14, dt.Minute, 2);
            chars[start + 16] = ':';
            DateTimeUtils.CopyIntToCharArray(chars, start + 17, dt.Second, 2);
            int num2 = (int)(dt.Ticks % 10000000L);

            if (num2 != 0)
            {
                int num3 = 7;
                while (num2 % 10 == 0)
                {
                    num3--;
                    num2 /= 10;
                }
                chars[start + 19] = '.';
                DateTimeUtils.CopyIntToCharArray(chars, start + 20, num2, num3);
                num += num3 + 1;
            }
            return(start + num);
        }
Example #2
0
        internal static int WriteDefaultIsoDate(char[] chars, int start, DateTime dt)
        {
            int num;
            int num1;
            int num2;
            int num3 = 19;

            DateTimeUtils.GetDateValues(dt, out num, out num1, out num2);
            DateTimeUtils.CopyIntToCharArray(chars, start, num, 4);
            chars[start + 4] = '-';
            DateTimeUtils.CopyIntToCharArray(chars, start + 5, num1, 2);
            chars[start + 7] = '-';
            DateTimeUtils.CopyIntToCharArray(chars, start + 8, num2, 2);
            chars[start + 10] = 'T';
            DateTimeUtils.CopyIntToCharArray(chars, start + 11, dt.Hour, 2);
            chars[start + 13] = ':';
            DateTimeUtils.CopyIntToCharArray(chars, start + 14, dt.Minute, 2);
            chars[start + 16] = ':';
            DateTimeUtils.CopyIntToCharArray(chars, start + 17, dt.Second, 2);
            int ticks = (int)(dt.Ticks % 10000000L);

            if (ticks != 0)
            {
                int num4 = 7;
                while (ticks % 10 == 0)
                {
                    num4--;
                    ticks /= 10;
                }
                chars[start + 19] = '.';
                DateTimeUtils.CopyIntToCharArray(chars, start + 20, ticks, num4);
                num3 = num3 + num4 + 1;
            }
            return(start + num3);
        }
        internal static int WriteDefaultIsoDate(char[] chars, int start, DateTime dt)
        {
            int num1 = 19;
            int year;
            int month;
            int day;

            DateTimeUtils.GetDateValues(dt, out year, out month, out day);
            DateTimeUtils.CopyIntToCharArray(chars, start, year, 4);
            chars[start + 4] = '-';
            DateTimeUtils.CopyIntToCharArray(chars, start + 5, month, 2);
            chars[start + 7] = '-';
            DateTimeUtils.CopyIntToCharArray(chars, start + 8, day, 2);
            chars[start + 10] = 'T';
            DateTimeUtils.CopyIntToCharArray(chars, start + 11, dt.Hour, 2);
            chars[start + 13] = ':';
            DateTimeUtils.CopyIntToCharArray(chars, start + 14, dt.Minute, 2);
            chars[start + 16] = ':';
            DateTimeUtils.CopyIntToCharArray(chars, start + 17, dt.Second, 2);
            int num2 = (int)(dt.Ticks % 10000000L);

            if (num2 != 0)
            {
                int digits = 7;
                for (; num2 % 10 == 0; num2 /= 10)
                {
                    --digits;
                }
                chars[start + 19] = '.';
                DateTimeUtils.CopyIntToCharArray(chars, start + 20, num2, digits);
                num1 += digits + 1;
            }
            return(start + num1);
        }
        internal static int WriteDateTimeOffset(char[] chars, int start, TimeSpan offset, DateFormatHandling format)
        {
            chars[start++] = ((offset.Ticks >= 0L) ? '+' : '-');
            int value = Math.Abs(offset.Hours);

            DateTimeUtils.CopyIntToCharArray(chars, start, value, 2);
            start += 2;
            if (format == DateFormatHandling.IsoDateFormat)
            {
                chars[start++] = ':';
            }
            int value2 = Math.Abs(offset.Minutes);

            DateTimeUtils.CopyIntToCharArray(chars, start, value2, 2);
            start += 2;
            return(start);
        }
Example #5
0
        internal static int WriteDateTimeOffset(char[] chars, int start, TimeSpan offset, DateFormatHandling format)
        {
            char[] chrArray = chars;
            int    num      = start;

            start         = num + 1;
            chrArray[num] = (offset.Ticks >= 0L ? '+' : '-');
            int num1 = Math.Abs(offset.Hours);

            DateTimeUtils.CopyIntToCharArray(chars, start, num1, 2);
            start += 2;
            if (format == DateFormatHandling.IsoDateFormat)
            {
                int num2 = start;
                start       = num2 + 1;
                chars[num2] = ':';
            }
            int num3 = Math.Abs(offset.Minutes);

            DateTimeUtils.CopyIntToCharArray(chars, start, num3, 2);
            start += 2;
            return(start);
        }