Nigel Rantor / azure_c_shared_utility

Fork of azure_c_shared_utility by Azure IoT

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers agenttime.h Source File

agenttime.h

Go to the documentation of this file.
00001 // Copyright (c) Microsoft. All rights reserved.
00002 // Licensed under the MIT license. See LICENSE file in the project root for full license information.
00003 
00004 /** @file agenttime.h
00005 *   @brief Function prototypes for time related functions.
00006 *
00007 *   @details These functions are implemented with C standard functions,
00008 *   and therefore they are platform independent. But then a platform
00009 *   can replace these functions with its own implementation as necessary.
00010 */
00011 
00012 #ifndef AGENTTIME_H
00013 #define AGENTTIME_H
00014 
00015 #include <time.h>
00016 #include "azure_c_shared_utility/umock_c_prod.h"
00017 
00018 #ifdef __cplusplus
00019 extern "C"
00020 {
00021 #endif
00022 
00023 /** @brief Get current calendar time.
00024 *
00025 *   @details This function provides the same functionality as the
00026 *   standard C @c time() function.
00027 */
00028 MOCKABLE_FUNCTION(, time_t, get_time, time_t*, currentTime);
00029 
00030 /** @brief Get UTC in @c tm struct.
00031 *
00032 *   @details This function provides the same functionality as the
00033 *   standard C @c gmtime() function.
00034 */
00035 MOCKABLE_FUNCTION(, struct tm*, get_gmtime, time_t*, currentTime);
00036 
00037 /** @brief Get current time representation of the given calendar time.
00038 *
00039 *   @details This function provides the same functionality as the
00040 *   standard C @c mktime() function.
00041 */
00042 MOCKABLE_FUNCTION(, time_t, get_mktime, struct tm*, cal_time);
00043 
00044 /** @brief Gets a C-string representation of the given time.
00045 *
00046 *   @details This function provides the same functionality as the
00047 *   standard C @c ctime() function.
00048 */
00049 MOCKABLE_FUNCTION(, char*, get_ctime, time_t*, timeToGet);
00050 
00051 /** @brief Gets the difference in seconds between @c stopTime and
00052 *   @c startTime.
00053 *
00054 *   @details This function provides the same functionality as the
00055 *   standard C @c difftime() function.
00056 */
00057 MOCKABLE_FUNCTION(, double, get_difftime, time_t, stopTime, time_t, startTime);
00058 
00059 #ifdef __cplusplus
00060 }
00061 #endif
00062 
00063 #endif  // AGENTTIME_H