Index: trunk/Ohana/src/opihi/lib.data/convert.c
===================================================================
--- trunk/Ohana/src/opihi/lib.data/convert.c	(revision 2598)
+++ trunk/Ohana/src/opihi/lib.data/convert.c	(revision 4602)
@@ -1,3 +1,8 @@
 # include "convert.h"
+# define _XOPEN_SOURCE /* glibc2 needs this */
+# include <time.h>
+
+char *strptime(const char *s, const char *format, struct tm *tm);
+
   
 int hh_hms (double hh, int *hr, int *mn, double *sc) {
@@ -160,4 +165,51 @@
 
   return (status);
+}
+
+/***** convert 00:00:00 or 00:00 to 0 - 86400 ****/
+int hms_to_sec (char *string, time_t *second) {
+  
+  char *p;
+  struct tm time;
+
+  p = strptime (string, "%H:%M:%S", &time);
+  if (p != NULL) goto valid;
+
+  p = strptime (string, "%H:%M", &time);
+  if (p != NULL) goto valid;
+
+  return (FALSE);
+    
+valid:
+  if (*p) return (FALSE);
+  *second = time.tm_hour*3600 + time.tm_min*60 + time.tm_sec;
+  return (TRUE);
+}
+
+/***** convert Mon[@00:00:00] or 00:00 to 0 - 86400*7 ****/
+int day_to_sec (char *string, time_t *second) {
+  
+  char *p;
+  struct tm time;
+
+  bzero (&time, sizeof(time));
+  p = strptime (string, "%A@%H:%M:%S", &time);
+  if (p != NULL) goto valid;
+
+  p = strptime (string, "%A@%H:%M", &time);
+  if (p != NULL) goto valid;
+
+  p = strptime (string, "%A@%H", &time);
+  if (p != NULL) goto valid;
+
+  p = strptime (string, "%A", &time);
+  if (p != NULL) goto valid;
+
+  return (FALSE);
+
+valid:
+  if (*p) return (FALSE);
+  *second = time.tm_wday*86400 + time.tm_hour*3600 + time.tm_min*60 + time.tm_sec;
+  return (TRUE);
 }
 
