changeset 1372:268d9af9103f

Basis.readUtc
author Adam Chlipala <adam@chlipala.net>
date Tue, 28 Dec 2010 14:51:57 -0500
parents 4e5ca2a77a4d
children 04bd0d91b74c
files include/urweb.h lib/ur/basis.urs src/c/urweb.c
diffstat 3 files changed, 14 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/include/urweb.h	Mon Dec 27 12:08:00 2010 -0500
+++ b/include/urweb.h	Tue Dec 28 14:51:57 2010 -0500
@@ -320,4 +320,6 @@
 void uw_setQueryString(uw_context, uw_Basis_string);
 uw_Basis_string uw_queryString(uw_context);
 
+uw_Basis_time *uw_Basis_readUtc(uw_context, uw_Basis_string);
+
 #endif
--- a/lib/ur/basis.urs	Mon Dec 27 12:08:00 2010 -0500
+++ b/lib/ur/basis.urs	Tue Dec 28 14:51:57 2010 -0500
@@ -144,6 +144,7 @@
 val minTime : time
 val addSeconds : time -> int -> time
 val timef : string -> time -> string (* Uses strftime() format string *)
+val readUtc : string -> option time
 
 
 (** * Encryption *)
--- a/src/c/urweb.c	Mon Dec 27 12:08:00 2010 -0500
+++ b/src/c/urweb.c	Tue Dec 28 14:51:57 2010 -0500
@@ -3661,3 +3661,14 @@
   return !!(uw_Basis_eq_time(ctx, t1, t2) || uw_Basis_lt_time(ctx, t1, t2));
 }
 
+uw_Basis_time *uw_Basis_readUtc(uw_context ctx, uw_Basis_string s) {
+  uw_Basis_time *r = uw_Basis_stringToTime(ctx, s);
+
+  if (r) {
+    struct tm tm;
+    localtime_r(&r->seconds, &tm);
+    r->seconds -= tm.tm_gmtoff;
+  }
+
+  return r;
+}