<?php
# Global functions used everywhere
+# $Id$
$wgNumberOfArticles = -1; # Unset
$wgTotalViews = -1;
wfSuppressWarnings( true );
}
+# Autodetect, convert and provide timestamps of various types
+define("TS_UNIX",0); # Standard unix timestamp
+define("TS_MW",1); # Mediawiki concatenated string timestamp (yyyymmddhhmmss)
+define("TS_DB",2); # Standard database timestamp (yyyy-mm-dd hh:mm:ss)
+
+function wfTimestamp($outputtype=TS_UNIX,$ts=0) {
+ if (preg_match("/^(\d{4})\-(\d\d)\-(\d\d) (\d\d):(\d\d):(\d\d)$/",$ts,$da)) {
+ # TS_DB
+ $uts=gmmktime((int)$da[4],(int)$da[5],(int)$da[6],
+ (int)$da[2],(int)$da[3],(int)$da[1]);
+ } elseif (preg_match("/^(\d{4})(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)$/",$ts,$da)) {
+ # TS_MW
+ $uts=gmmktime((int)$da[4],(int)$da[5],(int)$da[6],
+ (int)$da[2],(int)$da[3],(int)$da[1]);
+ } elseif (preg_match("/^(\d{1,13})$/",$ts,$datearray)) {
+ # TS_UNIX
+ $uts=$ts;
+ }
+
+ if ($ts==0)
+ $uts=time();
+ switch($outputtype) {
+ case TS_UNIX:
+ return $uts;
+ break;
+ case TS_MW:
+ return gmdate( "YmdHis", $uts );
+ break;
+ case TS_DB:
+ return gmdate( "Y-m-d H:i:s", $uts );
+ break;
+ default:
+ return;
+ }
+}
+
?>