Esempio n. 1
0
        public PeriodValue plus(PeriodValue period)
        {
            double seconds  = (double)(this.Seconds + period.Seconds) + (((double)(this.Millis + period.Millis)) / 1000.0);
            double millis_d = Math.Round(seconds * 1000, 0);
            int    millis   = Math.Abs((int)millis_d % 1000);

            return(new PeriodValue(
                       this.Years + period.Years,
                       this.Months + period.Months,
                       this.Weeks + period.Weeks,
                       this.Days + period.Days,
                       this.Hours + period.Hours,
                       this.Minutes + period.Minutes,
                       (int)seconds,
                       millis));
        }
Esempio n. 2
0
 public override bool Equals(object obj)
 {
     if (obj is PeriodValue)
     {
         PeriodValue period = (PeriodValue)obj;
         return(this.Years == period.Years &&
                this.Months == period.Months &&
                this.Weeks == period.Weeks &&
                this.Days == period.Days &&
                this.Hours == period.Hours &&
                this.Minutes == period.Minutes &&
                this.Seconds == period.Seconds &&
                this.Millis == period.Millis);
     }
     else
     {
         return(false);
     }
 }
Esempio n. 3
0
 internal DateTimeValue plus(PeriodValue period)
 {
     return(new DateTimeValue(this.value.AddYears(period.Years).AddMonths(period.Months).AddDays(period.Weeks * 7).AddDays(period.Days)
                              .AddHours(period.Hours).AddMinutes(period.Minutes).AddSeconds(period.Seconds).AddMilliseconds(period.Millis)));
 }
Esempio n. 4
0
 internal DateValue plus(PeriodValue period)
 {
     return(new DateValue(this.value.AddYears(period.Years).AddMonths(period.Months).AddDays(period.Weeks * 7).AddDays(period.Days)));
 }
Esempio n. 5
0
 public DateValue minus(PeriodValue period)
 {
     return(new DateValue(this.value.AddYears(-period.Years).AddMonths(-period.Months).AddDays(-period.Weeks * 7).AddDays(-period.Days)));
 }
Esempio n. 6
0
        internal TimeValue plus(PeriodValue period)
        {
            TimeSpan p = new TimeSpan(0, period.Hours, period.Minutes, period.Seconds, period.Millis);

            return(new TimeValue(value.Add(p)));
        }
Esempio n. 7
0
        public TimeValue minus(PeriodValue period)
        {
            TimeSpan p = new TimeSpan(0, period.Hours, period.Minutes, period.Seconds, period.Millis);

            return(new TimeValue(value.Subtract(p)));
        }