예제 #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));
        }
예제 #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);
     }
 }
예제 #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)));
 }
예제 #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)));
 }
예제 #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)));
 }
예제 #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)));
        }
예제 #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)));
        }