annotate show_time_as_float.c @ 98:d714f5ea83d7 draft default tip

planemo upload commit 1a01065a084a817382872154f779b94090a35ebf
author rhpvorderman
date Wed, 10 Jan 2024 12:32:47 +0000
parents 8fcf31272f6e
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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 }