#endif
#ifdef MAIN_C
-const char *const Weekdays[] = {
- "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat",
-};
-const char *const Months[] = {
- "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul",
- "Aug", "Sep", "Oct", "Nov", "Dec", "ERR",
-};
-
const char *const BodyTypes[] = {
"x-unknown", "audio", "application", "image", "message",
"model", "multipart", "text", "video",
"x-unknown", "7bit", "8bit", "quoted-printable",
"base64", "binary", "x-uuencoded",
};
-#else
-extern const char *const Weekdays[];
-extern const char *const Months[];
#endif
#endif /* _MUTT_GLOBALS_H */
* | Function | Description
* | :-------------------- | :--------------------------------------------------
* | mutt_local_tz() | Calculate the local timezone in seconds east of UTC
+ * | mutt_make_date() | Write a date in RFC822 format to a buffer
* | mutt_mktime() | Convert `struct tm` to `time_t`
* | mutt_normalize_time() | Fix the contents of a struct tm
*/
#include "config.h"
+#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
#include <time.h>
#define TM_YEAR_MAX \
(1970 + (((((TIME_T_MAX - 59) / 60) - 59) / 60) - 23) / 24 / 366)
+const char *const Weekdays[] = {
+ "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat",
+};
+const char *const Months[] = {
+ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul",
+ "Aug", "Sep", "Oct", "Nov", "Dec", "ERR",
+};
+
/**
* compute_tz - Calculate the number of seconds east of UTC
* @param g Local time
}
}
}
+
+/**
+ * mutt_make_date - Write a date in RFC822 format to a buffer
+ * @param buf Buffer for result
+ * @param buflen Length of buffer
+ * @retval ptr Buffer containing result
+ */
+char *mutt_make_date(char *buf, size_t buflen)
+{
+ time_t t = time(NULL);
+ struct tm *l = localtime(&t);
+ time_t tz = mutt_local_tz(t);
+
+ tz /= 60;
+
+ snprintf(buf, buflen, "Date: %s, %d %s %d %02d:%02d:%02d %+03d%02d\n",
+ Weekdays[l->tm_wday], l->tm_mday, Months[l->tm_mon], l->tm_year + 1900,
+ l->tm_hour, l->tm_min, l->tm_sec, (int) tz / 60, (int) abs((int) tz) % 60);
+ return buf;
+}
+
#include <time.h>
+extern const char *const Weekdays[];
+extern const char *const Months[];
+
time_t mutt_local_tz(time_t t);
time_t mutt_mktime(struct tm *t, int local);
void mutt_normalize_time(struct tm *tm);
+char *mutt_make_date(char *buf, size_t buflen);
#endif /* _LIB_DATE_H */
char *mutt_gecos_name(char *dest, size_t destlen, struct passwd *pw);
char *mutt_get_body_charset(char *d, size_t dlen, struct Body *b);
struct List *mutt_crypt_hook(struct Address *adr);
-char *mutt_make_date(char *s, size_t len);
void mutt_timeout_hook(void);
void mutt_startup_shutdown_hook(int type);
int mutt_set_xdg_path(enum XdgType type, char *buf, size_t bufsize);
return b;
}
-char *mutt_make_date(char *s, size_t len)
-{
- time_t t = time(NULL);
- struct tm *l = localtime(&t);
- time_t tz = mutt_local_tz(t);
-
- tz /= 60;
-
- snprintf(s, len, "Date: %s, %d %s %d %02d:%02d:%02d %+03d%02d\n",
- Weekdays[l->tm_wday], l->tm_mday, Months[l->tm_mon], l->tm_year + 1900,
- l->tm_hour, l->tm_min, l->tm_sec, (int) tz / 60, (int) abs((int) tz) % 60);
- return s;
-}
-
/**
* mutt_write_address_list - wrapper around mutt_write_address()
*