BUGFIX Fixed month conversion in DateField_View_JQuery::convert_iso_to_jquery_format() (fixes #6124, thanks mbren and natmchugh) (from r113247)

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@114523 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Sam Minnee 2010-12-05 08:20:13 +00:00
parent c3fa7406ab
commit 662f581b24
2 changed files with 28 additions and 3 deletions

View File

@ -614,12 +614,18 @@ class DateField_View_JQuery {
'/e/' => 'N',
'/D/' => '',
'/w/' => '',
// make single "M" lowercase
'/([^M])M([^M])/' => '$1m$2',
// make single "M" at start of line lowercase
'/^M([^M])/' => 'm$1',
// make single "M" at end of line lowercase
'/([^M])M$/' => '$1m',
// match exactly three capital Ms not preceeded or followed by an M
'/(?<!M)MMM(?!M)/' => 'M',
// match exactly two capital Ms not preceeded or followed by an M
'/(?<!M)MM(?!M)/' => 'mm',
// match four capital Ms (maximum allowed)
'/MMMM/' => 'MM',
'/MMM/' => 'M',
'/MM/' => 'mm',
'/l/' => '',
'/YYYY/' => 'yy',
'/yyyy/' => 'yy',

View File

@ -16,9 +16,28 @@ class DateFieldViewJQueryTest extends SapphireTest {
DateField_View_JQuery::convert_iso_to_jquery_format('d/MM/yyyy')
);
$this->assertEquals(
'dd.m.yy',
DateField_View_JQuery::convert_iso_to_jquery_format('dd.M.yyyy'),
'Month, no leading zero'
);
$this->assertEquals(
'dd.mm.yy',
DateField_View_JQuery::convert_iso_to_jquery_format('dd.MM.yyyy')
DateField_View_JQuery::convert_iso_to_jquery_format('dd.MM.yyyy'),
'Month, two digit'
);
$this->assertEquals(
'dd.M.yy',
DateField_View_JQuery::convert_iso_to_jquery_format('dd.MMM.yyyy'),
'Abbreviated month name'
);
$this->assertEquals(
'dd.MM.yy',
DateField_View_JQuery::convert_iso_to_jquery_format('dd.MMMM.yyyy'),
'Full month name'
);
}
}