diff options
author | 2010-12-28 14:51:57 -0500 | |
---|---|---|
committer | 2010-12-28 14:51:57 -0500 | |
commit | c3a91028d8cb4c5e47996cf5baf55778769acb75 (patch) | |
tree | 6df5ed722eb232892944a12fa51429f0f6801447 | |
parent | 5cab93a0031e80264226f44ff986c62b65b03c5e (diff) |
Basis.readUtc
-rw-r--r-- | include/urweb.h | 2 | ||||
-rw-r--r-- | lib/ur/basis.urs | 1 | ||||
-rw-r--r-- | src/c/urweb.c | 11 |
3 files changed, 14 insertions, 0 deletions
diff --git a/include/urweb.h b/include/urweb.h index dbbfec38..6ce541d1 100644 --- a/include/urweb.h +++ b/include/urweb.h @@ -320,4 +320,6 @@ int uw_buffer_append(uw_buffer *, const char *, size_t); 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 diff --git a/lib/ur/basis.urs b/lib/ur/basis.urs index a2881cf0..b002a419 100644 --- a/lib/ur/basis.urs +++ b/lib/ur/basis.urs @@ -144,6 +144,7 @@ val now : transaction time val minTime : time val addSeconds : time -> int -> time val timef : string -> time -> string (* Uses strftime() format string *) +val readUtc : string -> option time (** * Encryption *) diff --git a/src/c/urweb.c b/src/c/urweb.c index b78c4c82..2858fefc 100644 --- a/src/c/urweb.c +++ b/src/c/urweb.c @@ -3661,3 +3661,14 @@ uw_Basis_bool uw_Basis_le_time(uw_context ctx, uw_Basis_time t1, uw_Basis_time t 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; +} |