gpstime.c
Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2013 Swift Navigation Inc.
00003  * Contact: Fergus Noble <fergus@swift-nav.com>
00004  *
00005  * This source is subject to the license found in the file 'LICENSE' which must
00006  * be be distributed together with this source. All other rights reserved.
00007  *
00008  * THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
00009  * EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
00010  * WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
00011  */
00012 
00013 #include <math.h>
00014 
00015 #include "gpstime.h"
00016 
00024 gps_time_t normalize_gps_time(gps_time_t t)
00025 {
00026   while(t.tow < 0) {
00027     t.tow += 3600*24*7;
00028     t.wn += 1;
00029   }
00030 
00031   while(t.tow > 3600*24*7) {
00032     t.tow -= 3600*24*7;
00033     t.wn -= 1;
00034   }
00035 
00036   return t;
00037 }
00038 
00045 time_t gps2time(gps_time_t gps_t)
00046 {
00047   time_t t = GPS_EPOCH - GPS_MINUS_UTC_SECS;
00048 
00049   t += 7*24*3600*gps_t.wn;
00050   t += (s32)gps_t.tow;
00051 
00052   return t;
00053 }
00054 
00062 double gpsdifftime(gps_time_t end, gps_time_t beginning)
00063 {
00064   return (end.wn - beginning.wn)*7*24*3600 + \
00065          end.tow - beginning.tow;
00066 }
00067 
00068 


enu
Author(s): Mike Purvis
autogenerated on Fri Jan 3 2014 11:21:07