Mercurial > repos > davidvanzessen > shm_csr
annotate show_time_as_float.c @ 94:84e9e5c8c101 draft
"planemo upload commit d4be85014b638f1d50b318d4b735be7f6e973140"
author | rhpvorderman |
---|---|
date | Fri, 24 Mar 2023 16:58:28 +0000 |
parents | 8fcf31272f6e |
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 } |