internal static DateTime makeDT(Date d, Time t, TimeZone tz) { return new DateTime(d.m_year, d.m_month, d.m_day, t.m_hour, t.m_min, t.m_sec, t.m_ns, System.Int32.MaxValue, tz); }
////////////////////////////////////////////////////////////////////////// // Constructor - Date, Time ////////////////////////////////////////////////////////////////////////// internal static DateTime makeDT(Date d, Time t) { return makeDT(d, t, TimeZone.m_cur); }
public DateTime toDateTime(Date d, TimeZone tz) { return DateTime.makeDT(d, this, tz); }
public Duration minusDate(Date that) { // short circuit if equal if (this.Equals(that)) return Duration.Zero; // compute so that a < b Date a = this; Date b = that; if (a.compare(b) > 0) { b = this; a = that; } // compute difference in days long days = 0; if (a.m_year == b.m_year) { days = b.dayOfYear() - a.dayOfYear(); } else { days = (DateTime.isLeapYear(a.m_year) ? 366 : 365) - a.dayOfYear(); days += b.dayOfYear(); for (int i=a.m_year+1; i<b.m_year; ++i) days += DateTime.isLeapYear(i) ? 366 : 365; } // negate if necessary if a was this if (a == this) days = -days; // map days into ns ticks return Duration.make(days * Duration.nsPerDay); }
public DateTime toDateTime(Date d) { return DateTime.makeDT(d, this); }