Mercurial > repos > davidvanzessen > shm_csr
annotate show_time_as_float.c @ 93:8fcf31272f6e draft
planemo upload commit a43893724cc769bed8a1f19a5b19ec1ba20cb63c
author | rhpvorderman |
---|---|
date | Mon, 06 Mar 2023 11:36:32 +0000 |
parents | |
children |
rev | line source |
---|---|
93
8fcf31272f6e
planemo upload commit a43893724cc769bed8a1f19a5b19ec1ba20cb63c
rhpvorderman
parents:
diff
changeset
|
1 /* script adapted from https://www.nu42.com/2021/07/windows-c-time-in-nanoseconds.html */ |
8fcf31272f6e
planemo upload commit a43893724cc769bed8a1f19a5b19ec1ba20cb63c
rhpvorderman
parents:
diff
changeset
|
2 #include <stdio.h> |
8fcf31272f6e
planemo upload commit a43893724cc769bed8a1f19a5b19ec1ba20cb63c
rhpvorderman
parents:
diff
changeset
|
3 #include <time.h> |
8fcf31272f6e
planemo upload commit a43893724cc769bed8a1f19a5b19ec1ba20cb63c
rhpvorderman
parents:
diff
changeset
|
4 |
8fcf31272f6e
planemo upload commit a43893724cc769bed8a1f19a5b19ec1ba20cb63c
rhpvorderman
parents:
diff
changeset
|
5 int main(void) |
8fcf31272f6e
planemo upload commit a43893724cc769bed8a1f19a5b19ec1ba20cb63c
rhpvorderman
parents:
diff
changeset
|
6 { |
8fcf31272f6e
planemo upload commit a43893724cc769bed8a1f19a5b19ec1ba20cb63c
rhpvorderman
parents:
diff
changeset
|
7 struct timespec ts; |
8fcf31272f6e
planemo upload commit a43893724cc769bed8a1f19a5b19ec1ba20cb63c
rhpvorderman
parents:
diff
changeset
|
8 |
8fcf31272f6e
planemo upload commit a43893724cc769bed8a1f19a5b19ec1ba20cb63c
rhpvorderman
parents:
diff
changeset
|
9 if (timespec_get(&ts, TIME_UTC) != TIME_UTC) |
8fcf31272f6e
planemo upload commit a43893724cc769bed8a1f19a5b19ec1ba20cb63c
rhpvorderman
parents:
diff
changeset
|
10 { |
8fcf31272f6e
planemo upload commit a43893724cc769bed8a1f19a5b19ec1ba20cb63c
rhpvorderman
parents:
diff
changeset
|
11 fputs("timespec_get failed!", stderr); |
8fcf31272f6e
planemo upload commit a43893724cc769bed8a1f19a5b19ec1ba20cb63c
rhpvorderman
parents:
diff
changeset
|
12 return 1; |
8fcf31272f6e
planemo upload commit a43893724cc769bed8a1f19a5b19ec1ba20cb63c
rhpvorderman
parents:
diff
changeset
|
13 } |
8fcf31272f6e
planemo upload commit a43893724cc769bed8a1f19a5b19ec1ba20cb63c
rhpvorderman
parents:
diff
changeset
|
14 printf("%ld.%ld\n", ts.tv_sec, ts.tv_nsec); |
8fcf31272f6e
planemo upload commit a43893724cc769bed8a1f19a5b19ec1ba20cb63c
rhpvorderman
parents:
diff
changeset
|
15 return 0; |
8fcf31272f6e
planemo upload commit a43893724cc769bed8a1f19a5b19ec1ba20cb63c
rhpvorderman
parents:
diff
changeset
|
16 } |