* | #TimeZones | Lookup table of Time Zones
* | #Weekdays | Day of the week (abbreviated)
*
- * | Function | Description
- * | :-------------------- | :--------------------------------------------------
- * | imap_make_date() | Format date in IMAP style: DD-MMM-YYYY HH:MM:SS +ZZzz
- * | imap_parse_date() | Parse date of the form: DD-MMM-YYYY HH:MM:SS +ZZzz
- * | is_day_name() | Is the string a valid day name
- * | mutt_check_month() | Is the string a valid month name
- * | 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
- * | mutt_parse_date() | Parse a date string in RFC822 format
+ * | Function | Description
+ * | :------------------------- | :--------------------------------------------------
+ * | mutt_date_check_month() | Is the string a valid month name
+ * | mutt_date_is_day_name() | Is the string a valid day name
+ * | mutt_date_local_tz() | Calculate the local timezone in seconds east of UTC
+ * | mutt_date_make_date() | Write a date in RFC822 format to a buffer
+ * | mutt_date_make_imap() | Format date in IMAP style: DD-MMM-YYYY HH:MM:SS +ZZzz
+ * | mutt_date_make_time() | Convert `struct tm` to `time_t`
+ * | mutt_date_normalize_time() | Fix the contents of a struct tm
+ * | mutt_date_parse_date() | Parse a date string in RFC822 format
+ * | mutt_date_parse_imap() | Parse date of the form: DD-MMM-YYYY HH:MM:SS +ZZzz
*/
#include "config.h"
}
/**
- * mutt_local_tz - Calculate the local timezone in seconds east of UTC
+ * mutt_date_local_tz - Calculate the local timezone in seconds east of UTC
* @param t Time to examine
* @retval num Seconds east of UTC
*
* Returns the local timezone in seconds east of UTC for the time t,
* or for the current time if t is zero.
*/
-time_t mutt_local_tz(time_t t)
+time_t mutt_date_local_tz(time_t t)
{
/* Check we haven't overflowed the time (on 32-bit arches) */
if ((t == TIME_T_MAX) || (t == TIME_T_MIN))
}
/**
- * mutt_mktime - Convert `struct tm` to `time_t`
+ * mutt_date_make_time - Convert `struct tm` to `time_t`
* @param t Time to convert
* @param local Should the local timezone be considered
* @retval num Time in Unix format
* Convert a struct tm to time_t, but don't take the local timezone into
* account unless ``local'' is nonzero
*/
-time_t mutt_mktime(struct tm *t, int local)
+time_t mutt_date_make_time(struct tm *t, int local)
{
time_t g;
}
/**
- * mutt_normalize_time - Fix the contents of a struct tm
+ * mutt_date_normalize_time - Fix the contents of a struct tm
* @param tm Time to correct
*
* If values have been added/subtracted from a struct tm, it can lead to
*
* This function will correct any over/under-flow.
*/
-void mutt_normalize_time(struct tm *tm)
+void mutt_date_normalize_time(struct tm *tm)
{
static const char DaysPerMonth[12] = {
31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,
}
/**
- * mutt_make_date - Write a date in RFC822 format to a buffer
+ * mutt_date_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)
+char *mutt_date_make_date(char *buf, size_t buflen)
{
time_t t = time(NULL);
struct tm *l = localtime(&t);
- time_t tz = mutt_local_tz(t);
+ time_t tz = mutt_date_local_tz(t);
tz /= 60;
}
/**
- * mutt_check_month - Is the string a valid month name
+ * mutt_date_check_month - Is the string a valid month name
* @param s String to check
* @retval num Index into Months array (0-based)
* @retval -1 Error
* @note Only the first three characters are checked
* @note The comparison is case insensitive
*/
-int mutt_check_month(const char *s)
+int mutt_date_check_month(const char *s)
{
for (int i = 0; i < 12; i++)
if (mutt_strncasecmp(s, Months[i], 3) == 0)
}
/**
- * is_day_name - Is the string a valid day name
+ * mutt_date_is_day_name - Is the string a valid day name
* @param s String to check
* @retval boolean
*
* @note Only the first three characters are checked
* @note The comparison is case insensitive
*/
-bool is_day_name(const char *s)
+bool mutt_date_is_day_name(const char *s)
{
if ((strlen(s) < 3) || !*(s + 3) || !ISSPACE(*(s + 3)))
return false;
}
/**
- * mutt_parse_date - Parse a date string in RFC822 format
+ * mutt_date_parse_date - Parse a date string in RFC822 format
* @param[in] s String to parse
* @param[out] tz_out Pointer to timezone (optional)
* @retval num Unix time in seconds
*
* The 'timezone' field is optional; it defaults to +0000 if missing.
*/
-time_t mutt_parse_date(const char *s, struct Tz *tz_out)
+time_t mutt_date_parse_date(const char *s, struct Tz *tz_out)
{
int count = 0;
char *t = NULL;
break;
case 1: /* month of the year */
- i = mutt_check_month(t);
+ i = mutt_date_check_month(t);
if ((i < 0) || (i > 11))
return -1;
tm.tm_mon = i;
tz_out->zoccident = zoccident;
}
- time_t time = mutt_mktime(&tm, 0);
+ time_t time = mutt_date_make_time(&tm, 0);
/* Check we haven't overflowed the time (on 32-bit arches) */
if ((time != TIME_T_MAX) && (time != TIME_T_MIN))
time += tz_offset;
}
/**
- * imap_make_date - Format date in IMAP style: DD-MMM-YYYY HH:MM:SS +ZZzz
+ * mutt_date_make_imap - Format date in IMAP style: DD-MMM-YYYY HH:MM:SS +ZZzz
* @param buf Buffer to store the results
* @param buflen Length of buffer
* @param timestamp Time to format
*
* Caller should provide a buffer of at least 27 bytes.
*/
-int imap_make_date(char *buf, size_t buflen, time_t timestamp)
+int mutt_date_make_imap(char *buf, size_t buflen, time_t timestamp)
{
struct tm *tm = localtime(×tamp);
- time_t tz = mutt_local_tz(timestamp);
+ time_t tz = mutt_date_local_tz(timestamp);
tz /= 60;
}
/**
- * imap_parse_date - Parse date of the form: DD-MMM-YYYY HH:MM:SS +ZZzz
+ * mutt_date_parse_imap - Parse date of the form: DD-MMM-YYYY HH:MM:SS +ZZzz
* @param s Date in string form
* @retval 0 Error
* @retval time_t Unix time
*/
-time_t imap_parse_date(char *s)
+time_t mutt_date_parse_imap(char *s)
{
struct tm t;
time_t tz;
if (*s != '-')
return 0;
s++;
- t.tm_mon = mutt_check_month(s);
+ t.tm_mon = mutt_date_check_month(s);
s += 3;
if (*s != '-')
return 0;
if (s[0] == '+')
tz = -tz;
- return (mutt_mktime(&t, 0) + tz);
+ return (mutt_date_make_time(&t, 0) + tz);
}
bool has_agent = false; /* user defined user-agent header field exists */
if (mode == 0 && !privacy)
- fputs(mutt_make_date(buffer, sizeof(buffer)), fp);
+ fputs(mutt_date_make_date(buffer, sizeof(buffer)), fp);
/* OPT_USE_FROM is not consulted here so that we can still write a From:
* field if the user sets it with the `my_hdr' command
fseeko(fp, h->offset, SEEK_SET);
fprintf(f, "Resent-From: %s", resent_from);
- fprintf(f, "\nResent-%s", mutt_make_date(date, sizeof(date)));
+ fprintf(f, "\nResent-%s", mutt_date_make_date(date, sizeof(date)));
msgid_str = gen_msgid();
fprintf(f, "Resent-Message-ID: %s\n", msgid_str);
fputs("Resent-To: ", f);
/* mutt_write_rfc822_header() only writes out a Date: header with
* mode == 0, i.e. _not_ postponement; so write out one ourself */
if (post)
- fprintf(msg->fp, "%s", mutt_make_date(buf, sizeof(buf)));
+ fprintf(msg->fp, "%s", mutt_date_make_date(buf, sizeof(buf)));
/* (postponement) if the mail is to be signed or encrypted, save this info */
if ((WithCrypto & APPLICATION_PGP) && post && (hdr->security & APPLICATION_PGP))