1 | // Copyright (c) Microsoft. All rights reserved.
|
---|
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
---|
3 |
|
---|
4 | /** @file agenttime.h
|
---|
5 | * @brief Function prototypes for time related functions.
|
---|
6 | *
|
---|
7 | * @details These functions are implemented with C standard functions,
|
---|
8 | * and therefore they are platform independent. But then a platform
|
---|
9 | * can replace these functions with its own implementation as necessary.
|
---|
10 | */
|
---|
11 |
|
---|
12 | #ifndef AGENTTIME_H
|
---|
13 | #define AGENTTIME_H
|
---|
14 |
|
---|
15 | #include <time.h>
|
---|
16 | #include "umock_c/umock_c_prod.h"
|
---|
17 |
|
---|
18 | #ifdef __cplusplus
|
---|
19 | extern "C"
|
---|
20 | {
|
---|
21 | #endif
|
---|
22 |
|
---|
23 | /** @brief Get current calendar time.
|
---|
24 | *
|
---|
25 | * @details This function provides the same functionality as the
|
---|
26 | * standard C @c time() function.
|
---|
27 | */
|
---|
28 | MOCKABLE_FUNCTION(, time_t, get_time, time_t*, currentTime);
|
---|
29 |
|
---|
30 | /** @brief Get UTC in @c tm struct.
|
---|
31 | *
|
---|
32 | * @details This function provides the same functionality as the
|
---|
33 | * standard C @c gmtime() function.
|
---|
34 | */
|
---|
35 | MOCKABLE_FUNCTION(, struct tm*, get_gmtime, time_t*, currentTime);
|
---|
36 |
|
---|
37 | /** @brief Get current time representation of the given calendar time.
|
---|
38 | *
|
---|
39 | * @details This function provides the same functionality as the
|
---|
40 | * standard C @c mktime() function.
|
---|
41 | */
|
---|
42 | MOCKABLE_FUNCTION(, time_t, get_mktime, struct tm*, cal_time);
|
---|
43 |
|
---|
44 | /** @brief Gets a C-string representation of the given time.
|
---|
45 | *
|
---|
46 | * @details This function provides the same functionality as the
|
---|
47 | * standard C @c ctime() function.
|
---|
48 | */
|
---|
49 | MOCKABLE_FUNCTION(, char*, get_ctime, time_t*, timeToGet);
|
---|
50 |
|
---|
51 | /** @brief Gets the difference in seconds between @c stopTime and
|
---|
52 | * @c startTime.
|
---|
53 | *
|
---|
54 | * @details This function provides the same functionality as the
|
---|
55 | * standard C @c difftime() function.
|
---|
56 | */
|
---|
57 | MOCKABLE_FUNCTION(, double, get_difftime, time_t, stopTime, time_t, startTime);
|
---|
58 |
|
---|
59 | #ifdef __cplusplus
|
---|
60 | }
|
---|
61 | #endif
|
---|
62 |
|
---|
63 | #endif // AGENTTIME_H
|
---|