Ejemplo n.º 1
0
 public static YearMonthDurationValue Multiply(YearMonthDurationValue a, double b)
 {
     if (Double.IsNaN(b) || Double.IsNegativeInfinity(b) || Double.IsPositiveInfinity(b))
         throw new XQueryException(Properties.Resources.FOCA0005);
     int month = (int)Math.Floor(0.5 + DaysToMonth(a.HighPartValue.Days) * b);
     return new YearMonthDurationValue(new TimeSpan(MonthToDays(month), 0, 0, 0));
 }
Ejemplo n.º 2
0
 public static YearMonthDurationValue Divide(YearMonthDurationValue a, double b)
 {
     if (b == 0.0)
         throw new XQueryException(Properties.Resources.FOAR0001);
     if (Double.IsNaN(b))
         throw new XQueryException(Properties.Resources.FOCA0005);
     int month = (int)Math.Floor(0.5 + DaysToMonth(a.HighPartValue.Days) / b);
     return new YearMonthDurationValue(new TimeSpan(MonthToDays(month), 0, 0, 0));
 }
Ejemplo n.º 3
0
        public static DateValue Add(DateValue dat, YearMonthDurationValue duration)
        {
            try
            {

                Calendar calender = CultureInfo.InvariantCulture.Calendar;
                DateTime dt = dat.Value.DateTime;
                int year = dat.S ? -dt.Year : dt.Year - 1;
                int m = (dt.Month - 1) + duration.Months;
                year = year + duration.Years + m / 12;
                if (year >= 0)
                    year = year + 1;
                m = m % 12;
                if (m < 0)
                {
                    m += 12;
                    year -= 1;
                }
                m++;
                int day = Math.Min(dt.Day, calender.GetDaysInMonth(Math.Abs(year), m));
                if (year < 0)
                    dt = new DateTime(-year, m, day);
                else
                    dt = new DateTime(year, m, day);
                if (dat.IsLocal)
                    return new DateValue(year < 0, dt);
                else
                    return new DateValue(year < 0, new DateTimeOffset(dt, dat.Value.Offset));
            }
            catch (ArgumentOutOfRangeException)
            {
                throw new XQueryException(Properties.Resources.FODT0001);
            }
        }
Ejemplo n.º 4
0
 public static decimal Divide(YearMonthDurationValue a, YearMonthDurationValue b)
 {
     int month1 = DaysToMonth(a.HighPartValue.Days);
     int month2 = DaysToMonth(b.HighPartValue.Days);
     if (month2 == 0)
         throw new XQueryException(Properties.Resources.FOAR0001);
     return (decimal)month1 / (decimal)month2;
 }
Ejemplo n.º 5
0
 public Proxy(YearMonthDurationValue value)
 {
     _value = value;
 }