16#include "time_utils.h"
22static const char *
const month[12] = {
23 "january",
"february",
"march",
24 "april",
"may",
"june",
"july",
25 "august",
"september",
"october",
26 "november",
"december"};
39convert_date_time(dt, ct0)
43 register char *ptr, *ct;
63 for (i = 0; i < 12; i++)
64 if (strncmp(ptr, month[i], l) == 0)
78 while (*ct ==
' ' && *ct)
80 if (sscanf(ct,
"%ld:%ld", &(dt->hrs), &(dt->mins)) != 2)
87static const char *
const MonthAbbreviation[12] = {
88 "Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
89 "Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec"};
104 struct tm timeBreakdown;
107 while ((mt =
tmalloc((
unsigned)30 *
sizeof(*mt))) == NULL)
108 puts(
"allocation failure in mtime()");
110 if (!mdb_localtime_copy(&i, &timeBreakdown)) {
115 sprintf(mt,
"%d %s %02d %02d:%02d",
116 timeBreakdown.tm_mday,
117 MonthAbbreviation[timeBreakdown.tm_mon],
118 (timeBreakdown.tm_year + 1900) % 100,
119 timeBreakdown.tm_hour,
120 timeBreakdown.tm_min);
137 struct tm timeBreakdown;
140 while ((mt =
tmalloc((
unsigned)30 *
sizeof(*mt))) == NULL)
141 puts(
"allocation failure in mtime()");
143 if (!mdb_localtime_copy(&i, &timeBreakdown)) {
148 sprintf(mt,
"%d %s %02d %02d:%02d:%02d",
149 timeBreakdown.tm_mday,
150 MonthAbbreviation[timeBreakdown.tm_mon],
151 (timeBreakdown.tm_year + 1900) % 100,
152 timeBreakdown.tm_hour,
153 timeBreakdown.tm_min,
154 timeBreakdown.tm_sec);
void * tmalloc(uint64_t size_of_block)
Allocates a memory block of the specified size with zero initialization.
char * cp_str(char **s, char *t)
Copies a string, allocating memory for storage.
int get_long(long *iptr, char *s)
Parses a long integer value from the given string.
char * get_token(char *s)
Extracts the next token from the input string.
char * mtimes(void)
Generates a detailed formatted time string.
char * mtime(void)
Generates a formatted time string.