OK, here's a patch.

It makes Remind accept yyyy-mm-dd@hh:mm or yyyy-mm-ddThh:mm on input.

On output, there's a system variable called $DateTimeSep that defaults to '@'.
You can set it to 'T' instead:

    SET $DateTimeSep "T"

and then DATETIMEs are output in ISO 8601 format.

Regards,

Dianne.

diff --git a/src/custom.h b/src/custom.h
index 92b6964..4bf8a94 100644
--- a/src/custom.h
+++ b/src/custom.h
@@ -53,6 +53,13 @@
 /* #define TIMESEP '.' */
 
 /*---------------------------------------------------------------------*/
+/* DATETIMESEP:  The default datetime separator.  Default is '@';      */
+/* others may prefer 'T'.                                              */
+/*---------------------------------------------------------------------*/
+#define DATETIMESEP '@'
+/* #define DATETIMESEP '/' */
+
+/*---------------------------------------------------------------------*/
 /* ISOLATIN1: define it to 1 if you use the                            */
 /* ISO 8859-1 character set instead of ASCII.                          */
 /*---------------------------------------------------------------------*/
diff --git a/src/custom.h.in b/src/custom.h.in
index 92b6964..419be88 100644
--- a/src/custom.h.in
+++ b/src/custom.h.in
@@ -37,7 +37,7 @@
 /*---------------------------------------------------------------------*/
 #define DEFAULT_PAGE {"Letter", 612, 792}
 /* #define DEFAULT_PAGE {"A4", 595, 842} */
-  
+
 /*---------------------------------------------------------------------*/
 /* DATESEP:  The default date separator.  Standard usage is '-';       */
 /* others may prefer '/'.                                              */
@@ -53,6 +53,13 @@
 /* #define TIMESEP '.' */
 
 /*---------------------------------------------------------------------*/
+/* DATETIMESEP:  The default datetime separator.  Default is '@';      */
+/* others may prefer 'T'.                                              */
+/*---------------------------------------------------------------------*/
+#define DATETIMESEP '@'
+/* #define DATETIMESEP '/' */
+
+/*---------------------------------------------------------------------*/
 /* ISOLATIN1: define it to 1 if you use the                            */
 /* ISO 8859-1 character set instead of ASCII.                          */
 /*---------------------------------------------------------------------*/
diff --git a/src/expr.c b/src/expr.c
index 273c14b..d576f89 100644
--- a/src/expr.c
+++ b/src/expr.c
@@ -620,8 +620,8 @@ int DoCoerce(char type, Value *v)
            k = v->v.val % MINUTES_PER_DAY;
            h = k / 60;
            i = k % 60;
-           sprintf(CoerceBuf, "%04d%c%02d%c%02d@%02d%c%02d",
-                   y, DateSep, m+1, DateSep, d, h, TimeSep, i);
+           sprintf(CoerceBuf, "%04d%c%02d%c%02d%c%02d%c%02d",
+                   y, DateSep, m+1, DateSep, d, DateTimeSep, h, TimeSep, i);
            break;
        default: return E_CANT_COERCE;
        }
@@ -1193,7 +1193,7 @@ void PrintValue (Value *v, FILE *fp)
     }
     else if (v->type == DATETIME_TYPE) {
        FromJulian(v->v.val / MINUTES_PER_DAY, &y, &m, &d);
-       fprintf(fp, "%04d%c%02d%c%02d@%02d%c%02d", y, DateSep, m+1, DateSep, d,
+       fprintf(fp, "%04d%c%02d%c%02d%c%02d%c%02d", y, DateSep, m+1, DateSep, 
d, DateTimeSep,
                (v->v.val % MINUTES_PER_DAY) / 60, TimeSep, (v->v.val % 
MINUTES_PER_DAY) % 60);
     }
     else fprintf(fp, "ERR");
@@ -1261,7 +1261,7 @@ int ParseLiteralDate(char const **s, int *jul, int *tim)
     *jul = Julian(y, m, d);
 
     /* Do we have a time part as well? */
-    if (**s == ' ' || **s == '@') {
+    if (**s == ' ' || **s == '@' || **s == 'T' || **s == 't') {
        (*s)++;
        while(isdigit(**s)) {
            hour *= 10;
diff --git a/src/globals.h b/src/globals.h
index c2af693..370e8b8 100644
--- a/src/globals.h
+++ b/src/globals.h
@@ -73,6 +73,7 @@ EXTERN  INIT(   int     DontIssueAts, 0);
 EXTERN  INIT(   int     Daemon, 0);
 EXTERN  INIT(   char    DateSep, DATESEP);
 EXTERN  INIT(   char    TimeSep, TIMESEP);
+EXTERN  INIT(   char    DateTimeSep, DATETIMESEP);
 EXTERN  INIT(   int     SynthesizeTags, 0);
 EXTERN  INIT(   int     ScFormat, SC_AMPM);
 EXTERN  INIT(   int     MaxSatIter, 150);
diff --git a/src/var.c b/src/var.c
index cf933c2..52d6e7a 100644
--- a/src/var.c
+++ b/src/var.c
@@ -140,6 +140,25 @@ static int today_wday_func(int do_set, Value *val)
     return OK;
 }
 
+static int datetime_sep_func(int do_set, Value *val)
+{
+    if (!do_set) {
+       val->v.str = malloc(2);
+       if (!val->v.str) return E_NO_MEM;
+       val->v.str[0] = DateTimeSep;
+       val->v.str[1] = 0;
+       val->type = STR_TYPE;
+       return OK;
+    }
+    if (val->type != STR_TYPE) return E_BAD_TYPE;
+    if (strcmp(val->v.str, "T") &&
+       strcmp(val->v.str, "@")) {
+       return E_BAD_TYPE;
+    }
+    DateTimeSep = val->v.str[0];
+    return OK;
+}
+
 static int date_sep_func(int do_set, Value *val)
 {
     if (!do_set) {
@@ -575,6 +594,7 @@ static SysVar SysVarArr[] = {
     {"CalMode",        0,  INT_TYPE,     &DoCalendar,         0,      0   },
     {"Daemon",         0,  INT_TYPE,     &Daemon,             0,      0   },
     {"DateSep",        1,  SPECIAL_TYPE, date_sep_func,       0,      0   },
+    {"DateTimeSep",    1,  SPECIAL_TYPE, datetime_sep_func,   0,      0   },
     {"DefaultPrio",    1,  INT_TYPE,     &DefaultPrio,        0,      9999},
     {"DeltaOffset",    0,  INT_TYPE,     &DeltaOffset,        0,      0   },
     {"DontFork",       0,  INT_TYPE,     &DontFork,           0,      0   },
_______________________________________________
Remind-fans mailing list
Remind-fans@lists.roaringpenguin.com
http://lists.roaringpenguin.com/cgi-bin/mailman/listinfo/remind-fans
Remind is at http://www.roaringpenguin.com/products/remind

Reply via email to