public EarthTime subPsarTime(PsarTime et) { // Lets convert into EarthTime and then subtract like we normally would. EarthTime etEarthTime = convert(et); EarthTime thisEarthTime = new EarthTime(this.getYears(), this.getDays(), this.getHours(), this.getMinutes()); EarthTime diffTime = thisEarthTime.subEarthTime(etEarthTime); return diffTime; }
public EarthTime addPsarTime(PsarTime et) { // Converts a PsarTime object into a EarthTime object and adds them with the above method. EarthTime etEarthTime = convert(et); EarthTime thisEarthTime = new EarthTime(this.getYears(), this.getDays(), this.getHours(), this.getMinutes()); EarthTime sumTime = thisEarthTime.addEarthTime(etEarthTime); return sumTime; }
public EarthTime subEarthTime(EarthTime pt) { // The easiest way to deal with subtraction is to work with minutes, since // there wont be unit conversion issues. After converting and doing // the math, we convert back into proper clock units using our clockFriend. int totalMinute = (((this.getYears() * 365 * 24 * 60) + (this.getDays() * 24 * 60) + (this.getHours() * 60) + (this.getMinutes())) - ((pt.getYears() * 365 * 24 * 60) + (pt.getDays() * 24 * 60) + (pt.getHours() * 60) + (pt.getMinutes()))); return clockFriend(totalMinute); }
public EarthTime addEarthTime(EarthTime pt) { // Adds two EarthTime objects together and adjusts for proper clock-time // (i.e., clocks don't represent 61 minutes, but rather and 1 hour and 1 minute) int totalYears = this.getYears() + pt.getYears(); int totalDays = this.getDays() + pt.getDays(); int totalHours = this.getHours() + pt.getHours(); int totalMinute = this.getMinutes() + pt.getMinutes(); totalHours = totalHours + (totalMinute / 60); totalMinute = totalMinute % 60; totalDays = totalDays + (totalHours / 24); totalHours = totalHours % 24; totalYears = totalYears + (totalDays / 365); totalDays = totalDays % 365; EarthTime newpt = new EarthTime(totalYears, totalDays, totalHours, totalMinute); return newpt; }