public Duration toDuration() { return(Duration.make(m_hour * Duration.nsPerHr + m_min * Duration.nsPerMin + m_sec * Duration.nsPerSec + m_ns)); }
public Duration dstOffset(long year) { Rule r = rule((int)year); if (r.dstOffset == 0) { return(null); } return(Duration.make(r.dstOffset * Duration.nsPerSec)); }
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 Duration offset(long year) { return(Duration.make(rule((int)year).offset *Duration.nsPerSec)); }
public static Duration toDuration(long self) { return(Duration.make(self)); }
////////////////////////////////////////////////////////////////////////// // Operators ////////////////////////////////////////////////////////////////////////// public Duration minusDateTime(DateTime time) { return(Duration.make(m_ticks - time.m_ticks)); }