-
Notifications
You must be signed in to change notification settings - Fork 30
Expand file tree
/
Copy pathconvert_time.m
More file actions
50 lines (35 loc) · 837 Bytes
/
convert_time.m
File metadata and controls
50 lines (35 loc) · 837 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
%% convert_time.m
% Convert GPS time, calender time and UTC time to each other
% Author: Taro Suzuki
clear; close all; clc;
addpath ../
%% Calendar time vector
epochs = [2024 6 17 1 2 3;...
2024 6 17 1 2 4];
t1 = gt.Gtime(epochs);
disp("GPS time of week (s):");
disp(t1.tow);
disp("GPS week:");
disp(t1.week);
%% GPS time of week
t2 = gt.Gtime(t1.tow, t1.week);
disp("Calendar time vector:");
disp(t2.ep);
%% MATLAB date time
t3 = gt.Gtime(datetime("now","TimeZone","UTC")); % UTC
disp("Current time in UTC:");
disp(t3.t);
%% UTC to GPST
utcflag = true;
t4 = gt.Gtime(t3.ep, utcflag);
disp("Leap time:");
disp(t3.t-t4.t);
%% Day of year, Day of week, Seconds of day
disp("Current time:");
disp(t4.t);
disp("Day of year:");
disp(t4.doy);
disp("Day of week:");
disp(t4.dow);
disp("Seconds of day:");
disp(t4.sod);