Roxen.git/
server/
etc/
modules/
Roxen.pmod
Branch:
Tag:
Non-build tags
All tags
No tags
2009-11-26
2009-11-26 15:05:59 by Henrik Grubbström (Grubba) <grubba@grubba.org>
cc2ec9a3fbd6d177c25cbba910e8e74c99275007 (
33
lines) (+
32
/-
1
)
[
Show
|
Annotate
]
Branch:
5.2
Added convenience function timeout_dequantifier().
Rev: server/etc/modules/Roxen.pmod:1.283
1:
// This is a roxen pike module. Copyright © 1999 - 2009, Roxen IS. //
-
// $Id: Roxen.pmod,v 1.
282
2009/11/
19
23
:
50
:
26
mast
Exp $
+
// $Id: Roxen.pmod,v 1.
283
2009/11/
26
15
:
05
:
59
grubba
Exp $
#include <roxen.h> #include <config.h>
2968:
return (int)t; }
+
//! This function is typically used to conveniently calculate
+
//! timeout values for eg the @[roxen.ArgCache] and @[roxen.ImageCache].
+
//!
+
//! It's similar to @[time_dequantifier()], but returns time relative
+
//! to @expr{time(1)@}, and modifies the argument mapping @[args]
+
//! destructively.
+
//!
+
//! @returns
+
//! Returns @[UNDEFINED] if no timeout was specified, and seconds
+
//! since @expr{time(1)@} otherwise.
+
int timeout_dequantifier(mapping args)
+
{
+
int res = UNDEFINED;
+
+
if (args["unix-time"]) {
+
// "unix-time" isn't handled by time_dequantifier().
+
res = (int)args["unix-time"] - time(1);
+
}
+
+
res = time_dequantifier(args, res);
+
+
if (!zero_type(res)) {
+
foreach(({ "unix-time", "seconds", "minutes", "beats", "hours",
+
"days", "weeks", "months", "years" }), string arg) {
+
m_delete(args, arg);
+
}
+
}
+
return res;
+
}
+
class _charset_decoder(object cs) { string decode(string what)