summaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
authorKjartan Mannes <kjartan@2.no-reply.drupal.org>2001-07-17 09:04:33 +0000
committerKjartan Mannes <kjartan@2.no-reply.drupal.org>2001-07-17 09:04:33 +0000
commit934b3989e6b28f0405166b6e2b43f57aeb2d6552 (patch)
tree8a7a3f2a89161a90b7fc57acfff39c8bae26e2fb /includes
parented6cbd49810d7482562a4df68261252820a9f269 (diff)
downloadbrdo-934b3989e6b28f0405166b6e2b43f57aeb2d6552.tar.gz
brdo-934b3989e6b28f0405166b6e2b43f57aeb2d6552.tar.bz2
- moved format_size() from file.module to common.inc.
Diffstat (limited to 'includes')
-rw-r--r--includes/common.inc13
1 files changed, 13 insertions, 0 deletions
diff --git a/includes/common.inc b/includes/common.inc
index 8236e7075..953e2ebeb 100644
--- a/includes/common.inc
+++ b/includes/common.inc
@@ -116,6 +116,19 @@ function format_plural($count, $singular, $plural) {
return ($count == 1) ? "$count ". t($singular) : "$count ". t($plural);
}
+function format_size($size) {
+ $suffix = "bytes";
+ if ($size > 1024) {
+ $size = round($size / 1024, 2);
+ $suffix = "KB";
+ }
+ if ($size > 1024) {
+ $size = round($size / 1024, 2);
+ $suffix = "MB";
+ }
+ return "$size $suffix";
+}
+
function cache_clear($interval = 0) {
db_query("DELETE FROM cache WHERE ". time() ." - timestamp > $interval");
}