jiam912
November 28, 2017, 5:44am
1
Gents,
Kindly can u help with this.
I would like to get GPS time from UTC
Input
17/11/27 03:13:50:480000
17/11/27 03:12:54:380000
17/11/27 03:14:39:980000
output desired.
17/11/27 03:13:50:480000 1195787648480000
17/11/27 03:12:54:380000 1195787592380000
17/11/27 03:14:39:980000 1195787697980000
Appreciate your support.
RudiC
November 28, 2017, 6:01am
2
Any attempts / ideas / thoughts from your side? Do you have the conversion algorithms at hand?
1 Like
jiam912
November 28, 2017, 8:01am
3
RudiC
I got it as Unix Time
date +%s -ud "17/11/27 03:13:50"
but i dont know how to convert as desired
While most clocks derive their time from Coordinated Universal Time (UTC), the atomic clocks on the satellites are set to GPS time (GPST; see the page of United States Naval Observatory). The difference is that GPS time is not corrected to match the rotation of the Earth, so it does not contain leap seconds or other corrections that are periodically added to UTC. GPS time was set to match UTC in 1980, but has since diverged. The lack of corrections means that GPS time remains at a constant offset with International Atomic Time (TAI) (TAI � GPS = 19 seconds). Periodic corrections are performed to the on-board clocks to keep them synchronized with ground clocks.
Basically there is a nineteen second difference. And every time a leap second is applied to UTC you have to increment that number: currently 19 seconds, so 19 -> 20.
UTC to GPS Time Correction - Knowledge Base English - QPS Confluence
3 Likes
RudiC
November 28, 2017, 9:06am
5
Now this is becoming somewhat ridiculous, as on 14. Feb. 17 you yourself raised this question . What did people in here post their answers for?
3 Likes
jiam912
November 29, 2017, 8:59am
6
RudiC,
yes u are right about the previous question ( 14 feb ).
As u can see at that time I have the GPStime and the issue was to change the UTC time -3hrs.
The actual case is complete different as i need to get the GPStime from UTC.
Hope u understand
I am trying my self the possibility to solve it.
Appreciate your help
---------- Post updated 11-29-17 at 08:59 AM ---------- Previous update was 11-28-17 at 09:49 AM ----------
RudiC
I get the output desired using this code
ts=$(date -d'01/06/1980 00:00:00' +%s)
lap=18
cat file |
while read tt
do
dt=`echo $tt | awk '{print $1}' | awk -F"/" '{print $2"/"$3"/"$1}'`
tm=`echo $tt | awk '{print substr($2,1,8)}'`
ms=`echo $tt | awk '{print $2}' | awk -F":" '{print $NF}'`
line=`echo $dt" " $tm`
echo $line\ $(date -d "${line/// }" "+%s") |
awk '{print (($3 - '$ts') + '$lap')'$ms'}'
done
output
1195787648480000
1195787592380000
1195787697980000
Can u check if you can help me to do it in short code, please
jiam912
November 30, 2017, 9:29am
7
Gents,
Kindly, can you help to improve this code to be faster .. with 50000 lines in my file this take a lot time.
I appreciate your help.