DRObjects.DataStructures.DivineRightDateTime.GetTimeComponent C# (CSharp) Method

GetTimeComponent() public method

Gets some part of the time component based on the multiplier
public GetTimeComponent ( DRTimeComponent component ) : int
component DRTimeComponent
return int
        public int GetTimeComponent(DRTimeComponent component)
        {
            //First we divide time by the multiplier
            long dividedTime = Math.Abs( time / MULTIPLIERS[(int) component]);

            int returnValue = 0;

            //Then, except for years, remainder divide with the multiplier after it
            if ((int)component >= MULTIPLIERS.Length -1)
            {
                return (int)dividedTime;
            }
            else
            {
                returnValue = (int) (dividedTime % (MULTIPLIERS[(int)component + 1] / MULTIPLIERS[(int)component]));
            }

            if (component == DRTimeComponent.DAY || component == DRTimeComponent.MONTH)
            {
                //Increment by 1
                return returnValue + 1;
            }

            return returnValue;
        }