Hi all,
I'm still looking for a way to change the timestamp-format that comes the the
signature-button in the edit-window.
At the Moment, when I use the button "Ihre Signatur mit Zeitstempel" to
sign a text with adding a timestamp, the stamp has the following format:
09:57, 3. Jul. 2007 (CEST)
I'd like to change the timestamp-Format (and/or the DefaultDateFormat)
so that the timestamp looks like this:
03.06.2007, 09:57
After some searching I found the place where the signature is put together
according to the number of ~ used.
I've followed through the generation of the timestamp, but found my php is
definitly not fluent enough to even try to hack the code in order to get what I
want. :(
Also the note in parser.php sort of discourages me even further...
How can I change timestamp-format of the signature? Can any of you help me with
this?
To ease the way for those of you with more php-knowledge I've added those parts
of the code that is used in formatting the timestamp.
The generation of the signature and timestamp starts in includes/parser.php
/**
* Pre-save transform helper function
* @private
*/
function pstPass2( $text, &$stripState, $user ) {
global $wgContLang, $wgLocaltimezone;
/* Note: This is the timestamp saved as hardcoded wikitext to
* the database, we use $wgContLang here in order to give
* everyone the same signature and use the default one rather
* than the one selected in each user's preferences.
*/
if ( isset( $wgLocaltimezone ) ) {
$oldtz = getenv( 'TZ' );
putenv( 'TZ='.$wgLocaltimezone );
}
$d = $wgContLang->timeanddate( date( 'YmdHis' ), false, false) .
' (' . date( 'T' ) . ')';
if ( isset( $wgLocaltimezone ) ) {
putenv( 'TZ='.$oldtz );
}
# Variable replacement
# Because mOutputType is OT_WIKI, this will only process {{subst:xxx}} type tags
$text = $this->replaceVariables( $text );
# Strip out <nowiki> etc. added via replaceVariables
$text = $this->strip( $text, $stripState, false, array( 'gallery' ) );
# Signatures
$sigText = $this->getUserSig( $user );
$text = strtr( $text, array(
'~~~~~' => $d,
'~~~~' => "$sigText $d",
'~~~' => $sigText
) );
It continues in languages/language.php
/**
* @public
* @param mixed $ts the time format which needs to be turned into a
* date('YmdHis') format with wfTimestamp(TS_MW,$ts)
* @param bool $adj whether to adjust the time output according to the
* user configured offset ($timecorrection)
* @param mixed $format what format to return, if it's false output the
* default one (default true)
* @param string $timecorrection the time offset as returned by
* validateTimeZone() in Special:Preferences
* @return string
*/
function timeanddate( $ts, $adj = false, $format = true, $timecorrection = false) {
$this->load();
$ts = wfTimestamp( TS_MW, $ts );
if ( $adj ) {
$ts = $this->userAdjust( $ts, $timecorrection );
}
$pref = $this->dateFormat( $format );
if( $pref == 'default' || !isset( $this->dateFormats["$pref both"]
) ) {
$pref = $this->defaultDateFormat;
}
And finally the formatting of the timestamp is done in includes/GlobalFunctions.php
/**
* @param mixed $outputtype A timestamp in one of the supported formats, the
* function will autodetect which format is supplied
* and act accordingly.
* @return string Time in the format specified in $outputtype
*/
function wfTimestamp($outputtype=TS_UNIX,$ts=0) {
$uts = 0;
$da = array();
if ($ts==0) {
$uts=time();
} elseif (preg_match('/^(\d{4})\-(\d\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)$/D',$ts,$da))
{
# TS_EXIF
$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)$/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})$/D',$ts,$da)) {
# TS_UNIX
$uts = $ts;
} elseif (preg_match('/^(\d{1,2})-(...)-(\d\d(\d\d)?) (\d\d)\.(\d\d)\.(\d\d)/',
$ts, $da)) {
# TS_ORACLE
$uts = strtotime(preg_replace('/(\d\d)\.(\d\d)\.(\d\d)(\.(\d+))?/',
"$1:$2:$3",
str_replace("+00:00", "UTC", $ts)));
} elseif (preg_match('/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})Z$/',
$ts, $da)) {
# TS_ISO_8601
$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)[\+\-
](\d\d)$/',$ts,$da)) {
# TS_POSTGRES
$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)
GMT$/',$ts,$da)) {
# TS_POSTGRES
$uts=gmmktime((int)$da[4],(int)$da[5],(int)$da[6],
(int)$da[2],(int)$da[3],(int)$da[1]);
} else {
# Bogus value; fall back to the epoch...
wfDebug("wfTimestamp() fed bogus time value: $outputtype; $ts\n");
$uts = 0;
}
Greetings
Katharina Wolkwitz