]> andersk Git - moira.git/blobdiff - gen/util.c
mail.mit.edu domain.
[moira.git] / gen / util.c
index 9e8f2a91e0d496e0a9b2d133d21e17298f020f0a..d56ea3b23663c3a1a15af743d32907e7e5fcecef 100644 (file)
@@ -18,6 +18,9 @@
 
 RCSID("$Header$");
 
+/* Julian day of the UNIX epoch (January 1, 1970) */
+#define UNIX_EPOCH 2440588
+
 extern void sqlglm(char buf[], int *, int *);
 
 void fix_file(char *targetfile)
@@ -68,6 +71,17 @@ char *dequote(char *s)
   return s;
 }
 
+time_t unixtime(char *timestring)
+{
+  time_t t;
+
+  t = strtol(timestring, &timestring, 10) - UNIX_EPOCH;
+  t = t * 24 + strtol(timestring, &timestring, 10);
+  t = t * 60 + strtol(timestring, &timestring, 10);
+  t = t * 60 + strtol(timestring, &timestring, 10);
+
+  return t;
+}
 
 void db_error(int code)
 {
This page took 0.039862 seconds and 4 git commands to generate.