summaryrefslogtreecommitdiff
path: root/src/time
diff options
context:
space:
mode:
authorJakob Kaivo <jkk@ung.org>2020-08-16 15:55:19 -0400
committerJakob Kaivo <jkk@ung.org>2020-08-16 15:55:19 -0400
commite223e635cc53fa11e473cdbc864eb69a3da5f290 (patch)
treed481ca6fb0b7f4184f3ec259a6f9c37d76e56a26 /src/time
parent700fbd205a1a428677876d322606b9a354221892 (diff)
add skeleton of symbols from C11 LIB_EXT1
Diffstat (limited to 'src/time')
-rw-r--r--src/time/asctime_s.c43
-rw-r--r--src/time/ctime_s.c24
-rw-r--r--src/time/gmtime_s.c26
-rw-r--r--src/time/localtime_s.c25
4 files changed, 118 insertions, 0 deletions
diff --git a/src/time/asctime_s.c b/src/time/asctime_s.c
new file mode 100644
index 00000000..69f9fd33
--- /dev/null
+++ b/src/time/asctime_s.c
@@ -0,0 +1,43 @@
+#include "time.h"
+#include "stdio.h"
+
+/** convert broken down time to string **/
+errno_t asctime_s(char *s, rsize_t maxsize, const struct tm * timeptr)
+{
+ __C_EXT(1, 201112L);
+ static const char days[7][3] = {
+ "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
+ };
+ static const char months[12][3] = {
+ "Jan", "Feb", "Mar", "Apr", "May", "Jun",
+ "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
+ };
+ static char result[26];
+
+ sprintf(result, "%.3s %.3s%3d %.2d:%.2d:%.2d %d\n",
+ days[timeptr->tm_wday], months[timeptr->tm_mon],
+ timeptr->tm_mday, timeptr->tm_hour, timeptr->tm_min,
+ timeptr->tm_sec, timeptr->tm_year + 1900);
+ return result;
+}
+
+/***
+The fn(asctime) function converts the time specified at arg(timeptr) to a string
+in the format string(DDD MMM dd hh:mm:ss yyyy\n\0), where str(DDD) is the
+three-character abbreviated day of the week, str(MMM) is the three-character
+abbreviated month, string(dd) is the day of the month, str(hh) is the hour of
+the day (in the range (0,23)), str(mm) is the minute of the hour (in the range
+(0,59)), str(ss) is the second of the minute (in the range (0,61)), and
+str(yyyy) is the year.
+***/
+
+/* UNSPECIFIED: - */
+/* UNDEFINED: - */
+/* IMPLEMENTATION: - */
+/* LOCALE: - */
+
+/* RETURN: a pointer to the string */
+
+/*
+CEXT1(201112)
+*/
diff --git a/src/time/ctime_s.c b/src/time/ctime_s.c
new file mode 100644
index 00000000..8813247c
--- /dev/null
+++ b/src/time/ctime_s.c
@@ -0,0 +1,24 @@
+#include "time.h"
+
+/** convert arithmetic time to string **/
+errno_t ctime_s(char *s, rsize_t maxsize, const time_t *timer)
+{
+ __C_EXT(1, 201112L);
+ return asctime(localtime(timer));
+}
+
+/***
+The fn(ctime) converts the time at arg(timer) to a string in the same format as
+fn(asctime).
+***/
+
+/* UNSPECIFIED: - */
+/* UNDEFINED: - */
+/* IMPLEMENTATION: - */
+/* LOCALE: - */
+
+/* RETURN: a pointer to the string */
+
+/*
+CEXT1(201112)
+*/
diff --git a/src/time/gmtime_s.c b/src/time/gmtime_s.c
new file mode 100644
index 00000000..1629a651
--- /dev/null
+++ b/src/time/gmtime_s.c
@@ -0,0 +1,26 @@
+#include "time.h"
+
+/** convert arithmetic time to borken down time **/
+struct tm * gmtime_s(const time_t * restrict timer, struct tm * restrict result)
+{
+ __C_EXT(1, 201112L);
+ /* TODO */
+ return NULL;
+}
+
+/***
+The fn(gmtime) function converts the UTC time at arg(timer) to a filled out
+type(struct tm).
+***/
+
+/* UNSPECIFIED: - */
+/* UNDEFINED: - */
+/* IMPLEMENTATION: - */
+/* LOCALE: - */
+
+/* RETURN(NULL): UTC is not available */
+/* RETURN: a pointer to the converted structure */
+
+/*
+CEXT1(201112)
+*/
diff --git a/src/time/localtime_s.c b/src/time/localtime_s.c
new file mode 100644
index 00000000..f8ad731a
--- /dev/null
+++ b/src/time/localtime_s.c
@@ -0,0 +1,25 @@
+#include "time.h"
+
+/** convert arithmetic time to broken down time **/
+struct tm * localtime_s(const time_t * restrict timer, struct tm * restrict result)
+{
+ __C_EXT(1, 201112L);
+ /* TODO */
+ return NULL;
+}
+
+/***
+The fn(localtime) function converts the locale time at arg(timer) to a filled
+out type(struct tm).
+***/
+
+/* UNSPECIFIED: - */
+/* UNDEFINED: - */
+/* IMPLEMENTATION: - */
+/* LOCALE: - */
+
+/* RETURN: a pointer to the converted object */
+
+/*
+CEXT1(201112)
+*/