+2002-05-19 [alfons] 0.7.6claws5
+
+ * src/procheader.c
+ * src/procheader.h
+ add function for returning ime zone offset
+ * src/quote_fmt.c
+ * src/quote_fmt_parse.y
+ better quotation formatting - does not convert
+ to local time, but uses the original date string.
+
+ Note: %z inserts the timezone offset (should
+ work also on platforms where strftime does not
+ support %z).
+
2002-05-18 [christoph] 0.7.6claws4
* src/summaryview.c
MICRO_VERSION=6
INTERFACE_AGE=0
BINARY_AGE=0
-EXTRA_VERSION=claws4
+EXTRA_VERSION=claws5
VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION
dnl set $target
return -1;
}
+/*
+ * Hiro, most UNIXen support this function:
+ * http://www.mcsr.olemiss.edu/cgi-bin/man-cgi?getdate
+ */
+gboolean procheader_date_parse_to_tm(const gchar *src, struct tm *t, char *zone)
+{
+ static gchar monthstr[] = "JanFebMarAprMayJunJulAugSepOctNovDec";
+ gchar weekday[11];
+ gint day;
+ gchar month[10];
+ gint year;
+ gint hh, mm, ss;
+ GDateMonth dmonth;
+ gchar *p;
+ time_t timer;
+
+ if (!t)
+ return FALSE;
+
+ memset(t, 0, sizeof *t);
+
+ if (procheader_scan_date_string(src, weekday, &day, month, &year,
+ &hh, &mm, &ss, zone) < 0) {
+ g_warning("Invalid date: %s\n", src);
+ return FALSE;
+ }
+
+ /* Y2K compliant :) */
+ if (year < 100) {
+ if (year < 70)
+ year += 2000;
+ else
+ year += 1900;
+ }
+
+ month[3] = '\0';
+ if ((p = strstr(monthstr, month)) != NULL)
+ dmonth = (gint)(p - monthstr) / 3 + 1;
+ else {
+ g_warning("Invalid month: %s\n", month);
+ dmonth = G_DATE_BAD_MONTH;
+ }
+
+ t->tm_sec = ss;
+ t->tm_min = mm;
+ t->tm_hour = hh;
+ t->tm_mday = day;
+ t->tm_mon = dmonth - 1;
+ t->tm_year = year - 1900;
+ t->tm_wday = 0;
+ t->tm_yday = 0;
+ t->tm_isdst = -1;
+
+ return TRUE;
+}
+
time_t procheader_date_parse(gchar *dest, const gchar *src, gint len)
{
static gchar monthstr[] = "JanFebMarAprMayJunJulAugSepOctNovDec";
gchar *procheader_get_fromname (const gchar *str);
+gboolean procheader_date_parse_to_tm (const gchar *str,
+ struct tm *t,
+ char *zone);
+
time_t procheader_date_parse (gchar *dest,
const gchar *src,
gint len);
static gchar *symbol_table[][2] =
{
+ {"%D{fmt}", N_("Customize date format (see man strftime)")}, /* date expression */
{"%d", N_("Date")}, /* date */
{"%f", N_("From")}, /* from */
{"%N", N_("Full Name of Sender")}, /* full name */
#include "procmime.h"
#include "utils.h"
#include "intl.h"
+#include "procheader.h"
#include "quote_fmt.h"
#include "quote_fmt_lex.h"
}
| SHOW_DATE_EXPR OPARENT string CPARENT
{
- if (msginfo->date_t) {
- char timef[128];
- struct tm *lt;
-
- if (NULL != (lt = localtime(&msginfo->date_t))) {
- strftime(timef, sizeof timef, $3, lt);
- INSERT(timef);
+ /*
+ * ALF - GNU C's strftime() has a nice format specifier
+ * for time zone offset (%z). Non-standard however, so
+ * emulate it.
+ */
+ if (msginfo->date) {
+ char result[100];
+ char *rptr;
+ char zone[6];
+ struct tm lt;
+ const char *fptr;
+ const char *zptr;
+
+#define RLEFT (sizeof result) - (rptr - result)
+#define STR_SIZE(x) (sizeof (x) - 1)
+
+ zone[0] = 0;
+
+ if (procheader_date_parse_to_tm(msginfo->date, <, zone)) {
+ /*
+ * break up format string in tiny bits delimited by valid %z's and
+ * feed it to strftime(). don't forget that '%%z' mean literal '%z'.
+ */
+ for (rptr = result, fptr = $3; fptr && *fptr && rptr < &result[sizeof result - 1];) {
+ int perc;
+ const char *p;
+ char *tmp;
+
+ if (NULL != (zptr = strstr(fptr, "%z"))) {
+ /*
+ * count nr. of prepended percent chars
+ */
+ for (perc = 0, p = zptr; p && p >= $3 && *p == '%'; p--, perc++)
+ ;
+ /*
+ * feed to strftime()
+ */
+ tmp = g_strndup(fptr, zptr - fptr + (perc % 2 ? 0 : STR_SIZE("%z")));
+ if (tmp) {
+ rptr += strftime(rptr, RLEFT, tmp, <);
+ g_free(tmp);
+ }
+ /*
+ * append time zone offset
+ */
+ if (zone[0] && perc % 2)
+ rptr += g_snprintf(rptr, RLEFT, "%s", zone);
+ fptr = zptr + STR_SIZE("%z");
+ } else {
+ rptr += strftime(rptr, RLEFT, fptr, <);
+ fptr = NULL;
+ }
+ }
+
+ INSERT(result);
}
+#undef STR_SIZE
+#undef RLEFT
}
}
| SHOW_DATE