UTC to GPS

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.

:b:

Any attempts / ideas / thoughts from your side? Do you have the conversion algorithms at hand?

1 Like

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

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

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

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 :slight_smile:

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.