示例#1
0
        /// <summary>
        /// Sets the appropriate 9 bits in dates for this date at offset
        /// </summary>
        public void SetDateAtOffset(int offset, byte[] dates)
        {
            int start = (offset / 8) * 9;
            int date  = StupidDateList.IndexOf(this);

            switch (offset % 8)
            {
            case 0:
                dates[start]     = (byte)(date & 0xFF);
                dates[start + 1] = (byte)((dates[start + 1] & 0xFE) | (byte)((date & 0x100) >> 8));
                break;

            case 1:
                dates[start + 1] = (byte)((dates[start + 1] & 0x01) | (byte)((date & 0x7F) << 1));
                dates[start + 2] = (byte)((dates[start + 2] & 0xFC) | (byte)((date & 0x180) >> 7));
                break;

            case 2:
                dates[start + 2] = (byte)((dates[start + 2] & 0x03) | (byte)((date & 0x3F) << 2));
                dates[start + 3] = (byte)((dates[start + 3] & 0xF8) | (byte)((date & 0x1C0) >> 6));
                break;

            case 3:
                dates[start + 3] = (byte)((dates[start + 3] & 0x07) | (byte)((date & 0x1F) << 3));
                dates[start + 4] = (byte)((dates[start + 4] & 0xF0) | (byte)((date & 0x1E0) >> 5));
                break;

            case 4:
                dates[start + 4] = (byte)((dates[start + 4] & 0x0F) | (byte)((date & 0x0F) << 4));
                dates[start + 5] = (byte)((dates[start + 5] & 0xE0) | (byte)((date & 0x1F0) >> 4));
                break;

            case 5:
                dates[start + 5] = (byte)((dates[start + 5] & 0x1F) | (byte)((date & 0x07) << 5));
                dates[start + 6] = (byte)((dates[start + 6] & 0xC0) | (byte)((date & 0x1F8) >> 3));
                break;

            case 6:
                dates[start + 6] = (byte)((dates[start + 6] & 0x3F) | (byte)((date & 0x03) << 6));
                dates[start + 7] = (byte)((dates[start + 7] & 0x80) | (byte)((date & 0x1FC) >> 2));
                break;

            case 7:
                dates[start + 7] = (byte)((dates[start + 7] & 0x7F) | (byte)((date & 0x01) << 7));
                dates[start + 8] = (byte)((date & 0x1FE) >> 1);
                break;
            }
        }
示例#2
0
 public int ToInt()
 {
     return(StupidDateList.IndexOf(this));
 }