xref: /reactos/sdk/lib/ucrt/time/difftime.cpp (revision b09b5584)
1 //
2 // difftime.cpp
3 //
4 //      Copyright (c) Microsoft Corporation. All rights reserved.
5 //
6 // The difftime() family of functions, which compute the difference between time
7 // values.
8 //
9 #include <corecrt_internal_time.h>
10 
11 
12 
13 // Computes the difference between two times (b - a).  Returns a double with the
14 // difference in seconds between the two times.  Returns zero if the input is
15 // invalid.
16 template <typename TimeType>
17 static double __cdecl common_difftime(TimeType const b, TimeType const a) throw()
18 {
19     _VALIDATE_RETURN_NOEXC(a >= 0 && b >= 0, EINVAL, 0);
20 
21     return static_cast<double>(b - a);
22 }
23 
24 extern "C" double __cdecl _difftime32(__time32_t const b, __time32_t const a)
25 {
26     return common_difftime(b, a);
27 }
28 
29 extern "C" double __cdecl _difftime64(__time64_t const b, __time64_t const a)
30 {
31     return common_difftime(b, a);
32 }
33