Skip to content

Commit

Permalink
Merge pull request #5 from DataValues/fixCalendarTypo
Browse files Browse the repository at this point in the history
Correct multiple typos: Calend{e => a}r
  • Loading branch information
addshore committed Mar 10, 2014
2 parents 004ea71 + 695f5e8 commit 8461d7e
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 16 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ DataValues Time has been written by the Wikidata team, as [Wikimedia Germany]

## Release notes

### 0.3 (dev)

* Renamed CalenderModelParser to CalendarModelParser

### 0.2 (2014-02-11)

Added features:
Expand Down
2 changes: 1 addition & 1 deletion Time.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
return 1;
}

define( 'DATAVALUES_TIME_VERSION', '0.2' );
define( 'DATAVALUES_TIME_VERSION', '0.3' );

if ( defined( 'MEDIAWIKI' ) ) {
$GLOBALS['wgExtensionCredits']['datavalues'][] = array(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@
use ValueFormatters\TimeFormatter;

/**
* ValueParser that parses the string representation of a calender model.
* ValueParser that parses the string representation of a calendar model.
*
* @since 0.2
*
* @licence GNU GPL v2+
* @author Adam Shorland
*/
class CalenderModelParser extends StringValueParser {
class CalendarModelParser extends StringValueParser {

/**
* Regex pattern constant matching the parable calender models
* Regex pattern constant matching the parable calendar models
* should be used as an insensitive to match all cases
*/
const MODEL_PATTERN = '(Gregorian|Julian|)';
Expand All @@ -31,6 +31,6 @@ protected function stringParse( $value ) {
return TimeFormatter::CALENDAR_JULIAN;
}

throw new ParseException( 'Cannot parse calender model: ' . $value );
throw new ParseException( 'Cannot parse calendar model: ' . $value );
}
}
}
16 changes: 8 additions & 8 deletions src/ValueParsers/TimeParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,19 @@ class TimeParser extends StringValueParser {
const TIME_PATTERN = '(\d{1,16}\-\d{2}\-\d{2}T\d{2}:\d{2}:\d{2}Z)';

/**
* @var CalenderModelParser
* @var CalendarModelParser
*/
private $calenderModelParser;
private $calendarModelParser;

/**
* @since 0.1
*
* @param CalenderModelParser $calenderModelParser
* @param CalendarModelParser $calendarModelParser
* @param ParserOptions|null $options
*/
public function __construct( CalenderModelParser $calenderModelParser, ParserOptions $options = null ) {
public function __construct( CalendarModelParser $calendarModelParser, ParserOptions $options = null ) {
parent::__construct( $options );
$this->calenderModelParser = $calenderModelParser;
$this->calendarModelParser = $calendarModelParser;
}

protected function stringParse( $value ) {
Expand Down Expand Up @@ -110,7 +110,7 @@ private function getPrecisionFromYear( $year ) {
}

private function newTimeFromParts( $time, $model, $precision ) {
$model = $this->calenderModelParser->parse( $model );
$model = $this->calendarModelParser->parse( $model );
return new TimeValue( $time, 0, 0, 0, $precision, $model );
}

Expand All @@ -122,7 +122,7 @@ private function splitTimeString( $value ) {
$pattern = '@^'
. '\s*' . self::SIGN_PATTERN . '' // $1: sign
. '\s*' . self::TIME_PATTERN . '' // $2: time
. '\s*\(?\s*' . CalenderModelParser::MODEL_PATTERN . '\s*\)?' // $3 model
. '\s*\(?\s*' . CalendarModelParser::MODEL_PATTERN . '\s*\)?' // $3 model
. '\s*$@iu';

if ( !preg_match( $pattern, $value, $groups ) ) {
Expand All @@ -133,4 +133,4 @@ private function splitTimeString( $value ) {
return $groups;
}

}
}
4 changes: 2 additions & 2 deletions tests/ValueParsers/TimeParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace ValueFormatters\Test;

use DataValues\TimeValue;
use ValueParsers\CalenderModelParser;
use ValueParsers\CalendarModelParser;
use ValueParsers\Test\ValueParserTestBase;
use ValueFormatters\TimeFormatter;
use ValueParsers\TimeParser;
Expand Down Expand Up @@ -35,7 +35,7 @@ protected function getInstance() {
$options = $this->newParserOptions();

$class = $this->getParserClass();
return new $class( new CalenderModelParser(), $options );
return new $class( new CalendarModelParser(), $options );
}

/**
Expand Down

0 comments on commit 8461d7e

Please sign in to comment.