Skip to content

Commit

Permalink
Merge pull request #20 from Seldaek/dates
Browse files Browse the repository at this point in the history
Normalize all date-style formats
  • Loading branch information
alcohol committed Nov 3, 2015
2 parents efc2b2a + cf63fb6 commit 75975e3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/VersionParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public function normalize($version, $fullVersion = null)
$index = 5;
// match date(time) based versioning
} elseif (preg_match('{^v?(\d{4}(?:[.:-]?\d{2}){1,6}(?:[.:-]?\d{1,3})?)' . self::$modifierRegex . '$}i', $version, $matches)) {
$version = preg_replace('{\D}', '-', $matches[1]);
$version = preg_replace('{\D}', '.', $matches[1]);
$index = 2;
}

Expand Down
10 changes: 5 additions & 5 deletions tests/VersionParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,12 @@ public function successfulNormalizedVersions()
'parses dates y.m.Y as classical' => array('2010.1.555', '2010.1.555.0'),
'parses dates y.m.Y/2 as classical' => array('2010.10.200', '2010.10.200.0'),
'strips v/datetime' => array('v20100102', '20100102'),
'parses dates w/ -' => array('2010-01-02', '2010-01-02'),
'parses numbers' => array('2010-01-02.5', '2010-01-02-5'),
'parses dates w/ -' => array('2010-01-02', '2010.01.02'),
'parses numbers' => array('2010-01-02.5', '2010.01.02.5'),
'parses dates y.m.Y' => array('2010.1.555', '2010.1.555.0'),
'parses datetime' => array('20100102-203040', '20100102-203040'),
'parses dt+number' => array('20100102203040-10', '20100102203040-10'),
'parses dt+patch' => array('20100102-203040-p1', '20100102-203040-patch1'),
'parses datetime' => array('20100102-203040', '20100102.203040'),
'parses dt+number' => array('20100102203040-10', '20100102203040.10'),
'parses dt+patch' => array('20100102-203040-p1', '20100102.203040-patch1'),
'parses master' => array('dev-master', '9999999-dev'),
'parses trunk' => array('dev-trunk', '9999999-dev'),
'parses branches' => array('1.x-dev', '1.9999999.9999999.9999999-dev'),
Expand Down

0 comments on commit 75975e3

Please sign in to comment.