make pretty using clang-format 10
This commit is contained in:
+27
-35
@@ -561,12 +561,11 @@ static void seconds_since_midnight_into_hms(
|
||||
* @param btime [in] BACNET_TIME containing the time to convert
|
||||
*/
|
||||
void datetime_seconds_since_midnight_into_time(
|
||||
uint32_t seconds,
|
||||
BACNET_TIME *btime)
|
||||
uint32_t seconds, BACNET_TIME *btime)
|
||||
{
|
||||
if (btime) {
|
||||
seconds_since_midnight_into_hms(seconds,
|
||||
&btime->hour, &btime->min, &btime->sec);
|
||||
seconds_since_midnight_into_hms(
|
||||
seconds, &btime->hour, &btime->min, &btime->sec);
|
||||
btime->hundredths = 0;
|
||||
}
|
||||
}
|
||||
@@ -660,8 +659,7 @@ void datetime_add_minutes(BACNET_DATE_TIME *bdatetime, int32_t minutes)
|
||||
* @param bdatetime [in] the starting date and time
|
||||
* @return seconds since midnight
|
||||
*/
|
||||
uint64_t datetime_seconds_since_epoch(
|
||||
BACNET_DATE_TIME * bdatetime)
|
||||
uint64_t datetime_seconds_since_epoch(BACNET_DATE_TIME *bdatetime)
|
||||
{
|
||||
uint64_t seconds = 0;
|
||||
uint32_t days = 0;
|
||||
@@ -683,9 +681,7 @@ uint64_t datetime_seconds_since_epoch(
|
||||
* @param bdatetime [in] the starting date and time
|
||||
* @return seconds since midnight
|
||||
*/
|
||||
void datetime_since_epoch_seconds(
|
||||
BACNET_DATE_TIME * bdatetime,
|
||||
uint64_t seconds)
|
||||
void datetime_since_epoch_seconds(BACNET_DATE_TIME *bdatetime, uint64_t seconds)
|
||||
{
|
||||
uint32_t seconds_after_midnight = 0;
|
||||
uint32_t days = 0;
|
||||
@@ -1096,17 +1092,12 @@ int bacapp_decode_context_datetime(
|
||||
#include <string.h>
|
||||
#include "ctest.h"
|
||||
|
||||
static void datetime_print(const char *title,
|
||||
BACNET_DATE_TIME *bdatetime)
|
||||
static void datetime_print(const char *title, BACNET_DATE_TIME *bdatetime)
|
||||
{
|
||||
printf("%s: %04u/%02u/%02u %02u:%02u:%02u.%03u\n",
|
||||
title,
|
||||
(unsigned int)bdatetime->date.year,
|
||||
(unsigned int)bdatetime->date.month,
|
||||
(unsigned int)bdatetime->date.wday,
|
||||
(unsigned int)bdatetime->time.hour,
|
||||
(unsigned int)bdatetime->time.min,
|
||||
(unsigned int)bdatetime->time.sec,
|
||||
printf("%s: %04u/%02u/%02u %02u:%02u:%02u.%03u\n", title,
|
||||
(unsigned int)bdatetime->date.year, (unsigned int)bdatetime->date.month,
|
||||
(unsigned int)bdatetime->date.wday, (unsigned int)bdatetime->time.hour,
|
||||
(unsigned int)bdatetime->time.min, (unsigned int)bdatetime->time.sec,
|
||||
(unsigned int)bdatetime->time.hundredths);
|
||||
}
|
||||
|
||||
@@ -1423,22 +1414,25 @@ static void testDayOfYear(Test *pTest)
|
||||
}
|
||||
|
||||
static void testDateEpochConversionCompare(Test *pTest,
|
||||
uint16_t year, uint8_t month, uint8_t day,
|
||||
uint8_t hour, uint8_t minute, uint8_t second, uint8_t hundredth)
|
||||
uint16_t year,
|
||||
uint8_t month,
|
||||
uint8_t day,
|
||||
uint8_t hour,
|
||||
uint8_t minute,
|
||||
uint8_t second,
|
||||
uint8_t hundredth)
|
||||
{
|
||||
uint64_t epoch_seconds = 0;
|
||||
BACNET_DATE_TIME bdatetime = {0};
|
||||
BACNET_DATE_TIME test_bdatetime = {0};
|
||||
BACNET_DATE_TIME bdatetime = { 0 };
|
||||
BACNET_DATE_TIME test_bdatetime = { 0 };
|
||||
int compare = 0;
|
||||
|
||||
datetime_set_date(&bdatetime.date, year, month, day);
|
||||
datetime_set_time(&bdatetime.time, hour, minute, second,
|
||||
hundredth);
|
||||
datetime_set_time(&bdatetime.time, hour, minute, second, hundredth);
|
||||
epoch_seconds = datetime_seconds_since_epoch(&bdatetime);
|
||||
datetime_since_epoch_seconds(&test_bdatetime,
|
||||
epoch_seconds);
|
||||
compare = datetime_compare(&bdatetime,&test_bdatetime);
|
||||
ct_test(pTest,compare == 0);
|
||||
datetime_since_epoch_seconds(&test_bdatetime, epoch_seconds);
|
||||
compare = datetime_compare(&bdatetime, &test_bdatetime);
|
||||
ct_test(pTest, compare == 0);
|
||||
if (compare != 0) {
|
||||
datetime_print("bdatetime", &bdatetime);
|
||||
datetime_print("test_bdatetime", &test_bdatetime);
|
||||
@@ -1448,14 +1442,12 @@ static void testDateEpochConversionCompare(Test *pTest,
|
||||
static void testDateEpochConversion(Test *pTest)
|
||||
{
|
||||
/* min */
|
||||
testDateEpochConversionCompare(pTest,
|
||||
BACNET_EPOCH_YEAR, 1, 1, 0, 0, 0, 0);
|
||||
testDateEpochConversionCompare(pTest, BACNET_EPOCH_YEAR, 1, 1, 0, 0, 0, 0);
|
||||
/* middle */
|
||||
testDateEpochConversionCompare(pTest,
|
||||
2020, 6, 26, 12, 30, 30, 0);
|
||||
testDateEpochConversionCompare(pTest, 2020, 6, 26, 12, 30, 30, 0);
|
||||
/* max */
|
||||
testDateEpochConversionCompare(pTest,
|
||||
BACNET_EPOCH_YEAR + 0xFF - 1, 12, 31, 23, 59, 59, 0);
|
||||
testDateEpochConversionCompare(
|
||||
pTest, BACNET_EPOCH_YEAR + 0xFF - 1, 12, 31, 23, 59, 59, 0);
|
||||
}
|
||||
|
||||
static void testDateEpoch(Test *pTest)
|
||||
|
||||
Reference in New Issue
Block a user