comparison m-toolbox/classes/+utils/@timetools/utc2gps.m @ 0:f0afece42f48

Import.
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Wed, 23 Nov 2011 19:22:13 +0100
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:f0afece42f48
1 % UTC2GPS Converts UTC time to GPS seconds.
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 %
4 % DESCRIPTION: UTC2GPS Converts UTC time to GPS seconds.
5 % UTC_time can also be an array of UTC times.
6 %
7 % CALL: GPS_time=UTC2GPS(UTC_time)
8 %
9 % FORMAT: UTC time format: 'yyy-mm-dd- HH:MM:SS'
10 % GPS time format: Seconds since 6. January 1980
11 %
12 % EXAMPLES: GPS_time=UTC2GPS('2002-07-19 16:00:00')
13 % GPS_time=711129613
14 %
15 % GPS_time=UTC2GPS(['2002-07-19 16:00:00';'2001-07-19 16:00:00'])
16 % GPS_time=[711129613 ; 679593613]
17 %
18 % VERSION: $Id: utc2gps.m,v 1.2 2010/02/01 15:35:10 ingo Exp $
19 %
20 % HISTORY: xx-xx-xxxx Karsten Koetter
21 % Creation
22 % 24-01-2007 M Hewitson.
23 % Maintained
24 %
25 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
26
27 function GPS_time = utc2gps(UTC_time)
28
29 leapSecond = 15;
30
31 GPS_Epoch=datenum('01-06-1980 00:00:00')*86400;
32
33 [p q]=size(UTC_time);
34
35 for i=1:p
36 CurrUTC=UTC_time(i,:);
37 % reformt string to stupid matlab format MM-DD-YYY
38 CurrUTC=strcat(CurrUTC(6:10),'-',CurrUTC(1:4),CurrUTC(11:length(CurrUTC)));
39 NUM_time=datenum(CurrUTC)*86400;
40
41 GPS_time(i)=round(NUM_time-GPS_Epoch+leapSecond);
42 end
43
44 end
45