public static JsDate addMonths(this JsDate date, JsNumber months) { var date2 = new JsDate(date.valueOf()); date2.setMonth(date2.getMonth() + months); return(date2); }
/// <summary> /// Returns a new <see cref="T:System.DateTime"/> that adds the specified number of months 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 <paramref name="months"/>. /// </returns> /// <param name="months">A number of months. The <paramref name="months"/> parameter can be negative or positive. </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"/>.-or- <paramref name="months"/> is less than -120,000 or greater than 120,000. </exception><filterpriority>2</filterpriority> public DateTime AddMonths(int months) { var newDate = new JsDate(value.getTime()); newDate.setMonth(newDate.getMonth() + months); return(new DateTime(newDate)); }
/// <summary> /// Checks whether a given date is in daylight saving time. /// If the date supplied is after august, we assume that we're checking /// for southern hemisphere DST. /// </summary> private static bool DateIsDst(JsDate date) { var is_southern = date.getMonth() > 7; var base_offset = is_southern ? GetJuneOffset(date.getFullYear()) : GetJanuaryOffset(date.getFullYear()); var date_offset = GetDateOffset(date); var is_west = base_offset < 0; var dst_offset = base_offset - date_offset; if (!is_west && !is_southern) { return(dst_offset < 0); } return(dst_offset != 0); }
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)); }
public static JsDate removeTime(this JsDate date) { var date2 = new JsDate(date.getFullYear(), date.getMonth(), date.getDate()); return(date2); }
public static JsDate addMonths(this JsDate date, JsNumber months) { var date2 = new JsDate(date.valueOf()); date2.setMonth(date2.getMonth() + months); return date2; }
void foo5(object obj) { //dynamic result = obj; //JsArray data = new JsArray(); JsArray reminders = new JsArray();// DataUtils.toArray(result.PatientReminder); JsObject reminder; JsDate now = new JsDate(); JsDate startOfToday = new JsDate(now.getFullYear(), now.getMonth(), now.getDate(), 0, 0, 0, 0); JsDate dueDate; foreach (dynamic item in reminders) { dueDate = new JsDate(item.DueDate["$t"]); reminder = new JsObject(); reminder["Due"] = item.DueDate["$t"]; reminder["Done"] = item.PrevDate["$t"]; reminder["Subject"] = item.Description["$t"]; reminder["PastDue"] = dueDate.getTime() < startOfToday.getTime() ? "red" : ""; data.push(reminder); } //bool success = true; //if (success != null) //{ // success(data); //} }