public static JsDate addMilliseconds(this JsDate date, int miliseconds) { var date2 = new JsDate(date.valueOf()); date2.setMilliseconds(date2.getMilliseconds() + miliseconds); return(date2); }
/// <summary> /// Returns a new <see cref="T:System.DateTime"/> that adds the specified number of ticks to the value of this instance. /// </summary> /// /// <returns> /// An object whose value is the sum of the date and time represented by this instance and the time represented by <paramref name="value"/>. /// </returns> /// <param name="value">A number of 100-nanosecond ticks. The <paramref name="value"/> parameter can be positive or negative. </param><exception cref="T:System.ArgumentOutOfRangeException">The resulting <see cref="T:System.DateTime"/> is less than <see cref="F:System.DateTime.MinValue"/> or greater than <see cref="F:System.DateTime.MaxValue"/>. </exception><filterpriority>2</filterpriority> public DateTime AddTicks(long value) { var milliseconds = value / TimeSpan.TicksPerMillisecond; var newDate = new JsDate(this.value.getTime()); newDate.setMilliseconds(newDate.getMilliseconds() + (int)(milliseconds)); return(new DateTime(newDate)); }
public TimeSpan Subtract(DateTime value) { var utc1 = JsDate.UTC( date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds()).As <long>(); var utc2 = JsDate.UTC( value.As <JsImplDateTime>().date.getFullYear(), value.As <JsImplDateTime>().date.getMonth(), value.As <JsImplDateTime>().date.getDate(), value.As <JsImplDateTime>().date.getHours(), value.As <JsImplDateTime>().date.getMinutes(), value.As <JsImplDateTime>().date.getSeconds(), value.As <JsImplDateTime>().date.getMilliseconds()).As <long>(); var diff = utc1 - utc2; return(new TimeSpan(diff * TimeSpan.TicksPerMillisecond)); }