コード例 #1
0
ファイル: TimeIncrement.cs プロジェクト: kimbrano04/Base
        public static string GetTimeIDGivenIncrementsOnInputTimeId(string timeId, TimeIncrement increment)
        {
            var hour        = int.Parse(timeId.ToString().Substring(0, 2));
            var minute      = int.Parse(timeId.ToString().Substring(2, 2));
            var second      = int.Parse(timeId.ToString().Substring(4, 2));
            var milliSecond = int.Parse(timeId.ToString().Substring(6, 4));

            if (increment.type == TimeIncrementTypes.Hour)
            {
                hour = hour + increment.increments > 24 ? hour + increment.increments - 24 : hour + increment.increments;
            }
            if (increment.type == TimeIncrementTypes.Minute)
            {
                minute = minute + increment.increments > 60 ? minute + increment.increments - 60 : minute + increment.increments;
            }
            if (increment.type == TimeIncrementTypes.Second)
            {
                second = second + increment.increments > 60 ? second + increment.increments - 60 : second + increment.increments;
            }
            if (increment.type == TimeIncrementTypes.MilliSecond)
            {
                milliSecond = milliSecond + increment.increments > 1000 ? milliSecond + increment.increments - 1000 : milliSecond + increment.increments;
            }

            return(DoubleCharacterOut(hour.ToString()) + DoubleCharacterOut(minute.ToString()) + DoubleCharacterOut(second.ToString()));
        }
コード例 #2
0
ファイル: TimeIncrement.cs プロジェクト: kimbrano04/Base
        public static decimal GetTotalTimeUnitsInHours(TimeIncrement increment)
        {
            var hours = 0m;

            if (increment.type == TimeIncrementTypes.Hour)
            {
                hours = increment.increments;
            }
            if (increment.type == TimeIncrementTypes.Minute)
            {
                hours = increment.increments / (60m);
            }
            if (increment.type == TimeIncrementTypes.Second)
            {
                hours = increment.increments / (3600m);
            }
            if (increment.type == TimeIncrementTypes.MilliSecond)
            {
                hours = increment.increments / (3600000m);
            }

            return(hours);
        }