Пример #1
0
 private static ulong ReadUInt64(DirectBuffer db, int index, int length)
 {
     ulong ret = 0;
     for (int pos = 0; pos < length; pos++) {
         byte b = (byte)(db.ReadAsciiDigit(index + pos));
         if (b > 0) {
             ret += b * (ULongPower(10, (short)(length - pos - 1)));
         }
     }
     return ret;
 }
Пример #2
0
        private static long ReadHHMMSSXXXXXXAsUtcTicks(DateTime date, DirectBuffer db, int index)
        {
            // TODO method ReadAsciiDigit
            var hh = (db.ReadAsciiDigit(index)) * 10 + db.ReadAsciiDigit(index + 1);
            var mm = (db.ReadAsciiDigit(index + 2)) * 10 + db.ReadAsciiDigit(index + 3);
            var ss = (db.ReadAsciiDigit(index + 4)) * 10 + db.ReadAsciiDigit(index + 5);
            var micros = (db.ReadAsciiDigit(index + 6)) * 100000
                         + (db.ReadAsciiDigit(index + 7)) * 10000
                         + (db.ReadAsciiDigit(index + 8)) * 1000
                         + (db.ReadAsciiDigit(index + 9)) * 100
                         + (db.ReadAsciiDigit(index + 10)) * 10
                         + (db.ReadAsciiDigit(index + 11));
            var ticks = date.Date.Ticks
                        // hours
                        + hh * TimeSpan.TicksPerHour
                        // minutes
                        + mm * TimeSpan.TicksPerMinute
                        // seconds
                        + ss * TimeSpan.TicksPerSecond
                        // micros
                        + micros * 10;
            var dt = new DateTime(ticks, DateTimeKind.Unspecified);

            // this is pefromance killer - for the same date delta is always the same, should
            // calculate utc via ticks by adding pre-calculated delta
            //dt = dt.ConvertToUtcWithUncpecifiedKind("ny");

            return dt.Ticks;
        }