System.Xml.Schema.XsdDuration.Normalize C# (CSharp) Method

Normalize() public method

Normalize year-month part and day-time part so that month < 12, hour < 24, minute < 60, and second < 60.
public Normalize ( ) : XsdDuration
return XsdDuration
        public XsdDuration Normalize() {
            int years = Years;
            int months = Months;
            int days = Days;
            int hours = Hours;
            int minutes = Minutes;
            int seconds = Seconds;

            try {
                checked {
                    if (months >= 12) {
                        years += months / 12;
                        months %= 12;
                    }

                    if (seconds >= 60) {
                        minutes += seconds / 60;
                        seconds %= 60;
                    }

                    if (minutes >= 60) {
                        hours += minutes / 60;
                        minutes %= 60;
                    }

                    if (hours >= 24) {
                        days += hours / 24;
                        hours %= 24;
                    }
                }
            }
            catch (OverflowException) {
                throw new OverflowException(Res.GetString(Res.XmlConvert_Overflow, ToString(), "Duration"));
            }

            return new XsdDuration(IsNegative, years, months, days, hours, minutes, seconds, Nanoseconds);
        }