summaryrefslogtreecommitdiffstats
path: root/src/common.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/common.c')
-rw-r--r--src/common.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/common.c b/src/common.c
index 0b11d57..810c2e0 100644
--- a/src/common.c
+++ b/src/common.c
@@ -98,3 +98,18 @@ int num_digits_u(uint64_t i)
98 return n; 98 return n;
99} 99}
100#undef PO10u_LIMIT 100#undef PO10u_LIMIT
101
102int plist_real_to_time64(double realval, Time64_T *timev)
103{
104 if (!timev || !isfinite(realval)) {
105 return -1;
106 }
107
108 if (realval < (double)TIME64_MIN - (double)MAC_EPOCH ||
109 realval > (double)TIME64_MAX - (double)MAC_EPOCH) {
110 return -1;
111 }
112
113 *timev = (Time64_T)realval + MAC_EPOCH;
114 return 0;
115}