X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=blobdiff_plain;f=altoslib%2FAltosGPS.java;h=0b30ed456593f75587ca57b2ff6a7954810f82db;hp=a4cd20618f7c93345b488d5f703f2bc57ba07729;hb=a6701283af7ed2b3016a910d6edbe4a5e8304581;hpb=7041c386cdf37716f8daf0bc1a9204db620e3de9 diff --git a/altoslib/AltosGPS.java b/altoslib/AltosGPS.java index a4cd2061..0b30ed45 100644 --- a/altoslib/AltosGPS.java +++ b/altoslib/AltosGPS.java @@ -3,7 +3,8 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of @@ -15,13 +16,14 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_9; +package org.altusmetrum.altoslib_11; import java.text.*; import java.util.concurrent.*; import java.io.*; +import java.time.*; -public class AltosGPS implements Cloneable, Serializable { +public class AltosGPS implements Cloneable { public final static int MISSING = AltosLib.MISSING; @@ -72,6 +74,24 @@ public class AltosGPS implements Cloneable, Serializable { hour = minute = second = AltosLib.MISSING; } + /* Return time since epoc in seconds */ + public long seconds() { + if (year == AltosLib.MISSING) + return AltosLib.MISSING; + if (month == AltosLib.MISSING) + return AltosLib.MISSING; + if (day == AltosLib.MISSING) + return AltosLib.MISSING; + if (hour == AltosLib.MISSING) + return AltosLib.MISSING; + if (minute == AltosLib.MISSING) + return AltosLib.MISSING; + if (second == AltosLib.MISSING) + return AltosLib.MISSING; + OffsetDateTime odt = OffsetDateTime.of(year, month, day, hour, minute, second, 0, ZoneOffset.UTC); + return odt.toEpochSecond(); + } + public AltosGPS(AltosTelemetryMap map) throws ParseException { String state = map.get_string(AltosTelemetryLegacy.AO_TELEM_GPS_STATE, AltosTelemetryLegacy.AO_TELEM_GPS_STATE_ERROR);