MCPcopy Create free account
hub / github.com/MenoData/Time4J / getElapsedTime

Method getElapsedTime

base/src/main/java/net/time4j/Moment.java:832–908  ·  view source on GitHub ↗
(TimeScale scale)

Source from the content-addressed store, hash-verified

830 }
831
832 @Override
833 public long getElapsedTime(TimeScale scale) {
834
835 switch (scale) {
836 case POSIX:
837 return this.posixTime;
838 case UTC:
839 return this.getElapsedTimeUTC();
840 case TAI:
841 long tai;
842 int nano;
843 if (this.getElapsedTimeUTC() < 0) {
844 PlainDate date = this.getDateUTC();
845 double ttValue = TimeScale.deltaT(date);
846 ttValue += (this.posixTime - POSIX_UTC_DELTA);
847 ttValue += (this.getNanosecond() / (MRD * 1.0));
848 long tv = (long) Math.floor(ttValue);
849 if (Double.compare(MRD - (ttValue - tv) * MRD, 1.0) < 0) {
850 tv++;
851 nano = 0;
852 } else {
853 nano = toNanos(ttValue, tv);
854 }
855 tai = tv - 32 + UTC_TAI_DELTA;
856 nano -= 184_000_000;
857 if (nano < 0) {
858 tai--;
859 }
860 } else {
861 tai = this.getElapsedTimeUTC() + UTC_TAI_DELTA + 10;
862 }
863 if (tai < 0) {
864 throw new IllegalArgumentException(
865 "TAI not supported before 1958-01-01: " + this);
866 } else {
867 return tai;
868 }
869 case GPS:
870 long utcG = this.getElapsedTimeUTC();
871 if (LeapSeconds.getInstance().strip(utcG) < POSIX_GPS_DELTA) {
872 throw new IllegalArgumentException(
873 "GPS not supported before 1980-01-06: " + this);
874 } else {
875 long gps = LeapSeconds.getInstance().isEnabled() ? utcG : (utcG + 9);
876 return gps - UTC_GPS_DELTA;
877 }
878 case TT:
879 if (this.posixTime < POSIX_UTC_DELTA) {
880 PlainDate date = this.getDateUTC();
881 double ttValue = TimeScale.deltaT(date);
882 ttValue += (this.posixTime - POSIX_UTC_DELTA);
883 ttValue += (this.getNanosecond() / (MRD * 1.0));
884 long tt = (long) Math.floor(ttValue);
885 if (Double.compare(MRD - (ttValue - tt) * MRD, 1.0) < 0) {
886 return tt + 1;
887 }
888 return tt;
889 } else {

Callers 12

epochMethod · 0.95
getElapsedTimeUTCMethod · 0.95
getElapsedTimeTAIMethod · 0.95
getElapsedTimeGPSMethod · 0.95
getElapsedTimePOSIXMethod · 0.95
getElapsedTimeTTMethod · 0.95
getElapsedTimeUTMethod · 0.95
transformMethod · 0.95
transformForPrintMethod · 0.95
synchronizedWithMethod · 0.95

Calls 11

getElapsedTimeUTCMethod · 0.95
getDateUTCMethod · 0.95
deltaTMethod · 0.95
getNanosecondMethod · 0.95
toNanosMethod · 0.95
getInstanceMethod · 0.95
getModernUTMethod · 0.95
floorMethod · 0.80
compareMethod · 0.65
stripMethod · 0.45
isEnabledMethod · 0.45

Tested by 9

epochMethod · 0.76
getElapsedTimeUTCMethod · 0.76
getElapsedTimeTAIMethod · 0.76
getElapsedTimeGPSMethod · 0.76
getElapsedTimePOSIXMethod · 0.76
getElapsedTimeTTMethod · 0.76
getElapsedTimeUTMethod · 0.76