mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
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:
parent
c3fa7406ab
commit
662f581b24
@ -614,12 +614,18 @@ class DateField_View_JQuery {
|
|||||||
'/e/' => 'N',
|
'/e/' => 'N',
|
||||||
'/D/' => '',
|
'/D/' => '',
|
||||||
'/w/' => '',
|
'/w/' => '',
|
||||||
|
// make single "M" lowercase
|
||||||
'/([^M])M([^M])/' => '$1m$2',
|
'/([^M])M([^M])/' => '$1m$2',
|
||||||
|
// make single "M" at start of line lowercase
|
||||||
'/^M([^M])/' => 'm$1',
|
'/^M([^M])/' => 'm$1',
|
||||||
|
// make single "M" at end of line lowercase
|
||||||
'/([^M])M$/' => '$1m',
|
'/([^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',
|
'/MMMM/' => 'MM',
|
||||||
'/MMM/' => 'M',
|
|
||||||
'/MM/' => 'mm',
|
|
||||||
'/l/' => '',
|
'/l/' => '',
|
||||||
'/YYYY/' => 'yy',
|
'/YYYY/' => 'yy',
|
||||||
'/yyyy/' => 'yy',
|
'/yyyy/' => 'yy',
|
||||||
|
@ -16,9 +16,28 @@ class DateFieldViewJQueryTest extends SapphireTest {
|
|||||||
DateField_View_JQuery::convert_iso_to_jquery_format('d/MM/yyyy')
|
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(
|
$this->assertEquals(
|
||||||
'dd.mm.yy',
|
'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'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user