Example #1
0
        public static DateTime intTime2Time(Int32 time)
        {
            int year        = ToolType.intoRange(1, 1, 9999);
            int month       = ToolType.intoRange(1, 1, 12);
            int day         = ToolType.intoRange(1, 1, 31);
            int hour        = ToolType.intoRange((time >> 24), 1, 23);
            int minute      = ToolType.intoRange(((time << 8) >> 24), 0, 59);
            int second      = ToolType.intoRange(((time << 16) >> 24), 0, 59);
            int millisecond = ToolType.intoRange(0, 0, 999);

            return(new DateTime(year, month, day, hour, minute, second, millisecond));
        }
Example #2
0
        private DateTime setDateTimePatr(DateTime dt, DateParts dateParts, object val)
        {
            DateTime tmpDT;
            int      tmpInt;

            switch ((int)dateParts)
            {
            //case (int)DateParts.dateTime:
            //    return dt;
            case (int)DateParts.date:
                tmpDT = (DateTime)val;
                return(new DateTime(tmpDT.Year, tmpDT.Month, tmpDT.Day, dt.Hour, dt.Minute, dt.Second));

            case (int)DateParts.dateInt:
                tmpDT = ToolGeneral.intDate2Date((int)val);
                return(new DateTime(tmpDT.Year, tmpDT.Month, tmpDT.Day, dt.Hour, dt.Minute, dt.Second));

            case (int)DateParts.timeInt:
                tmpDT = ToolGeneral.intTime2Time((int)val);
                return(new DateTime(dt.Year, dt.Month, dt.Day, tmpDT.Hour, tmpDT.Minute, tmpDT.Second));

            case (int)DateParts.year:
                tmpInt = ToolType.intoRange(Convert.ToInt32(val), 1, 9999);
                return(new DateTime(tmpInt, dt.Month, dt.Day, dt.Hour, dt.Minute, dt.Second));

            case (int)DateParts.month:
                tmpInt = ToolType.intoRange(Convert.ToInt32(val), 1, 12);
                return(new DateTime(dt.Year, tmpInt, dt.Day, dt.Hour, dt.Minute, dt.Second));

            case (int)DateParts.day:
                tmpInt = ToolType.intoRange(Convert.ToInt32(val), 1, 31);
                return(new DateTime(dt.Year, dt.Month, tmpInt, dt.Hour, dt.Minute, dt.Second));

            case (int)DateParts.hour:
                tmpInt = ToolType.intoRange(Convert.ToInt32(val), 0, 23);
                return(new DateTime(dt.Year, dt.Month, dt.Day, tmpInt, dt.Minute, dt.Second));

            case (int)DateParts.minute:
                tmpInt = ToolType.intoRange(Convert.ToInt32(val), 0, 59);
                return(new DateTime(dt.Year, dt.Month, dt.Day, dt.Hour, tmpInt, dt.Second));

            case (int)DateParts.second:
                tmpInt = ToolType.intoRange(Convert.ToInt32(val), 0, 59);
                return(new DateTime(dt.Year, dt.Month, dt.Day, dt.Hour, dt.Minute, tmpInt));
            }
            return(dt);
        }