#include <signal.h>
#include <spawn.h>
#include <syslog.h>
-#include <tinyara/time.h>
+#include <time.h>
#include <sys/types.h>
+#include <math.h>
+#include <float.h>
#include "tc_internal.h"
#define BUFF_SIZE 64
TC_ASSERT_EQ("strftime", atoi(buffer), st_time.tm_mon + 1);
/* Check the abbreviated month name */
- strftime(buffer, BUFF_SIZE, "%b", &st_time);
+ strftime(buffer, BUFF_SIZE, "%h", &st_time);
TC_ASSERT_EQ("strftime", strcmp(buffer, "Jun"), 0);
/* Check the full month name */
strftime(buffer, BUFF_SIZE, "%d", &st_time);
TC_ASSERT_EQ("strftime", atoi(buffer), st_time.tm_mday);
+ /* Check the day of month as a decimal number but a leading zero
+ * is replaced by a space. (range 1 to 31)
+ */
+ strftime(buffer, BUFF_SIZE, "%e", &st_time);
+ TC_ASSERT_EQ("strftime", atoi(buffer), st_time.tm_mday);
+
/* Check the hour as a decimal number using a 24-hour clock (range 00 to 23) */
strftime(buffer, BUFF_SIZE, "%H", &st_time);
TC_ASSERT_EQ("strftime", atoi(buffer), st_time.tm_hour);
strftime(buffer, BUFF_SIZE, "%j", &st_time);
TC_ASSERT_EQ("strftime", atoi(buffer), clock_daysbeforemonth(st_time.tm_mon, false) + st_time.tm_mday);
+ /* Check the hour as a decimal number using a 24-hour clock (range 0 to 23)
+ * single digits are preceded by a blank.
+ */
+ strftime(buffer, BUFF_SIZE, "%k", &st_time);
+ TC_ASSERT_EQ("strftime", atoi(buffer), st_time.tm_hour);
+
+ /* Check the hour as a decimal number using a 12-hour clock (range 01 to 12)
+ * single digits are preceded by a blank.
+ */
+ strftime(buffer, BUFF_SIZE, "%l", &st_time);
+ TC_ASSERT_EQ("strftime", atoi(buffer), st_time.tm_hour - 12);
+
/* Check either "AM" or "PM" according to the given time value, Noon is treated as "PM" and midnight as "AM" */
strftime(buffer, BUFF_SIZE, "%p", &st_time);
TC_ASSERT_EQ("strftime", strcmp(buffer, "PM"), 0);
strftime(buffer, BUFF_SIZE, "%P", &st_time);
TC_ASSERT_EQ("strftime", strcmp(buffer, "pm"), 0);
+ st_time.tm_hour = 3;
+ /* Check either "AM" or "PM" according to the given time value, Noon is treated as "PM" and midnight as "AM" */
+ strftime(buffer, BUFF_SIZE, "%p", &st_time);
+ TC_ASSERT_EQ("strftime", strcmp(buffer, "AM"), 0);
+
+ /* Check either "am" or "pm" according to the given time value, Noon is treated as "pm" and midnight as "am" */
+ strftime(buffer, BUFF_SIZE, "%P", &st_time);
+ TC_ASSERT_EQ("strftime", strcmp(buffer, "am"), 0);
+
/* Check the second as a decimal number (range 00 to 60) */
strftime(buffer, BUFF_SIZE, "%S", &st_time);
TC_ASSERT_EQ("strftime", atoi(buffer), st_time.tm_sec);