Skip to content
This repository was archived by the owner on Sep 5, 2024. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/components/datepicker/dateLocale.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ describe('$mdDateLocale', function() {
expect(dateLocale.parseDate(dateStr)).toEqual(jasmine.any(Date));
});

it('should default to the US date formatting', function() {
var date = new Date(2014, 2, 25);
var dateStr = dateLocale.formatDate(date);
expect(dateStr).toBe('3/25/2014');
});

it('should have default date completion detection', function() {
// Valid dates.
expect(dateLocale.isDateComplete('04/05/15')).toBe(true);
Expand Down
4 changes: 2 additions & 2 deletions src/components/datepicker/dateLocaleProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@
* @param $locale
* @returns {DateLocale}
*/
DateLocaleProvider.prototype.$get = function($locale) {
DateLocaleProvider.prototype.$get = function($locale, $filter) {
/**
* Default date-to-string formatting function.
* @param {!Date} date
Expand All @@ -174,7 +174,7 @@
formatDate = new Date(date.getFullYear(), date.getMonth(), date.getDate(), 1, 0, 0);
}

return formatDate.toLocaleDateString();
return $filter('date')(formatDate, 'M/d/yyyy');
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/components/datepicker/datePicker.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ describe('md-date-picker', function() {
expect(pageScope.myDate).toEqual(date);
expect(controller.ngModelCtrl.$modelValue).toEqual(date);

expect(controller.inputElement.value).toEqual(date.toLocaleDateString());
expect(controller.inputElement.value).toEqual('6/1/2015');
expect(controller.calendarPaneOpenedFrom).toBe(null);
expect(controller.isCalendarOpen).toBe(false);
});
Expand Down