Index: trunk/extensions/ParserFunctions/ParserFunctions.i18n.php |
— | — | @@ -21,6 +21,7 @@ |
22 | 22 | 'default' => array( 0, '#default' ), |
23 | 23 | 'ifexist' => array( 0, 'ifexist' ), |
24 | 24 | 'time' => array( 0, 'time' ), |
| 25 | + 'timel' => array( 0, 'timel' ), |
25 | 26 | 'rel2abs' => array( 0, 'rel2abs' ), |
26 | 27 | 'titleparts' => array( 0, 'titleparts' ), |
27 | 28 | ); |
— | — | @@ -44,16 +45,17 @@ |
45 | 46 | * Hebrew |
46 | 47 | */ |
47 | 48 | $words['he'] = array( |
48 | | - 'expr' => array( 0, 'חשב', 'expr' ), |
49 | | - 'if' => array( 0, 'תנאי', 'if' ), |
50 | | - 'ifeq' => array( 0, 'שווה', 'ifeq' ), |
51 | | - 'ifexpr' => array( 0, 'חשב תנאי', 'ifexpr' ), |
52 | | - 'switch' => array( 0, 'בחר', 'switch' ), |
53 | | - 'default' => array( 0, '#ברירת מחדל', '#default' ), |
54 | | - 'ifexist' => array( 0, 'קיים', 'ifexist' ), |
55 | | - 'time' => array( 0, 'זמן', 'time' ), |
56 | | - 'rel2abs' => array( 0, 'יחסי למוחלט', 'rel2abs' ), |
57 | | - 'titleparts' => array( 0, 'חלק בכותרת', 'titleparts' ), |
| 49 | + 'expr' => array( 0, 'חשב', 'expr' ), |
| 50 | + 'if' => array( 0, 'תנאי', 'if' ), |
| 51 | + 'ifeq' => array( 0, 'שווה', 'ifeq' ), |
| 52 | + 'ifexpr' => array( 0, 'חשב תנאי', 'ifexpr' ), |
| 53 | + 'switch' => array( 0, 'בחר', 'switch' ), |
| 54 | + 'default' => array( 0, '#ברירת מחדל', '#default' ), |
| 55 | + 'ifexist' => array( 0, 'קיים', 'ifexist' ), |
| 56 | + 'time' => array( 0, 'זמן', 'time' ), |
| 57 | + 'timel' => array( 0, 'זמןמ', 'timel' ), |
| 58 | + 'rel2abs' => array( 0, 'יחסי למוחלט', 'rel2abs' ), |
| 59 | + 'titleparts' => array( 0, 'חלק בכותרת', 'titleparts' ), |
58 | 60 | ); |
59 | 61 | |
60 | 62 | /** |
Index: trunk/extensions/ParserFunctions/ParserFunctions.php |
— | — | @@ -182,10 +182,10 @@ |
183 | 183 | return $else; |
184 | 184 | } |
185 | 185 | |
186 | | - function time( &$parser, $format = '', $date = '' ) { |
187 | | - global $wgContLang; |
188 | | - if ( isset( $this->mTimeCache[$format][$date] ) ) { |
189 | | - return $this->mTimeCache[$format][$date]; |
| 186 | + function time( &$parser, $format = '', $date = '', $local = false ) { |
| 187 | + global $wgContLang, $wgLocaltimezone; |
| 188 | + if ( isset( $this->mTimeCache[$format][$date][$local] ) ) { |
| 189 | + return $this->mTimeCache[$format][$date][$local]; |
190 | 190 | } |
191 | 191 | |
192 | 192 | if ( $date !== '' ) { |
— | — | @@ -201,7 +201,21 @@ |
202 | 202 | if ( $this->mTimeChars > $this->mMaxTimeChars ) { |
203 | 203 | return wfMsgForContent( 'pfunc_time_too_long' ); |
204 | 204 | } else { |
205 | | - $ts = wfTimestamp( TS_MW, $unix ); |
| 205 | + if ( $local ) { |
| 206 | + # Use the time zone |
| 207 | + if ( isset( $wgLocaltimezone ) ) { |
| 208 | + $oldtz = getenv( 'TZ' ); |
| 209 | + putenv( 'TZ='.$wgLocaltimezone ); |
| 210 | + } |
| 211 | + wfSuppressWarnings(); // E_STRICT system time bitching |
| 212 | + $ts = date( 'YmdHis', $unix ); |
| 213 | + wfRestoreWarnings(); |
| 214 | + if ( isset( $wgLocaltimezone ) ) { |
| 215 | + putenv( 'TZ='.$oldtz ); |
| 216 | + } |
| 217 | + } else { |
| 218 | + $ts = wfTimestamp( TS_MW, $unix ); |
| 219 | + } |
206 | 220 | if ( method_exists( $wgContLang, 'sprintfDate' ) ) { |
207 | 221 | $result = $wgContLang->sprintfDate( $format, $ts ); |
208 | 222 | } else { |
— | — | @@ -213,10 +227,14 @@ |
214 | 228 | } |
215 | 229 | } |
216 | 230 | } |
217 | | - $this->mTimeCache[$format][$date] = $result; |
| 231 | + $this->mTimeCache[$format][$date][$local] = $result; |
218 | 232 | return $result; |
219 | 233 | } |
220 | 234 | |
| 235 | + function localTime( &$parser, $format = '', $date = '' ) { |
| 236 | + return $this->time( $parser, $format, $date, true ); |
| 237 | + } |
| 238 | + |
221 | 239 | /** |
222 | 240 | * Obtain a specified number of slash-separated parts of a title, |
223 | 241 | * e.g. {{#titleparts:Hello/World|1}} => "Hello" |
— | — | @@ -264,6 +282,7 @@ |
265 | 283 | $wgParser->setFunctionHook( 'switch', array( &$wgExtParserFunctions, 'switchHook' ) ); |
266 | 284 | $wgParser->setFunctionHook( 'ifexist', array( &$wgExtParserFunctions, 'ifexist' ) ); |
267 | 285 | $wgParser->setFunctionHook( 'time', array( &$wgExtParserFunctions, 'time' ) ); |
| 286 | + $wgParser->setFunctionHook( 'timel', array( &$wgExtParserFunctions, 'localTime' ) ); |
268 | 287 | $wgParser->setFunctionHook( 'rel2abs', array( &$wgExtParserFunctions, 'rel2abs' ) ); |
269 | 288 | $wgParser->setFunctionHook( 'titleparts', array( &$wgExtParserFunctions, 'titleparts' ) ); |
270 | 289 | |