Don't pass negative years to Language::sprintfDate

Language::sprintfDate cannot handle negative years, so don't pass them.
Return an appropriate error instead.

Change-Id: Ifb633631df98c82aa1c3dc8a555b91f77faf15ed
This commit is contained in:
Brad Jorsch 2013-04-19 17:26:03 -04:00
parent 2ef8c54041
commit 203b3e75dc

View file

@ -261,7 +261,9 @@ class Scribunto_LuaLanguageLibrary extends Scribunto_LuaLibraryBase {
# Generate timestamp
$ts = $dateObject->format( 'YmdHis' );
if ( $ts >= 100000000000000 ) {
if ( $ts < 0 ) {
throw new Scribunto_LuaError( "mw.language:formatDate() only supports years from 0" );
} elseif ( $ts >= 100000000000000 ) {
throw new Scribunto_LuaError( "mw.language:formatDate() only supports years up to 9999" );
}