Skip to content

Commit dd338e5

Browse files
committedAug 12, 2013
Merge pull request smalot#105 from wagnervaz/master
Added option to set default date format in the language settings
2 parents 68afa80 + d4b24d2 commit dd338e5

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed
 

‎README.md

+9
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,15 @@ $.fn.datetimepicker.dates['en'] = {
484484
};
485485
```
486486

487+
You can override the default date format in the language configuration with `format` attribute.
488+
Example:
489+
490+
```javascript
491+
$.fn.datetimepicker.dates['pt-BR'] = {
492+
format: 'dd/mm/yyyy'
493+
};
494+
```
495+
487496
Right-to-left languages may also include `rtl: true` to make the calendar display appropriately.
488497

489498
If your browser (or those of your users) is displaying characters wrong, chances are the browser is loading the javascript file with a non-unicode encoding. Simply add `charset="UTF-8"` to your `script` tag:

‎js/bootstrap-datetimepicker.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
this.language = this.language in dates ? this.language : "en";
4040
this.isRTL = dates[this.language].rtl || false;
4141
this.formatType = options.formatType || this.element.data('format-type') || 'standard';
42-
this.format = DPGlobal.parseFormat(options.format || this.element.data('date-format') || DPGlobal.getDefaultFormat(this.formatType, 'input'), this.formatType);
42+
this.format = DPGlobal.parseFormat(options.format || this.element.data('date-format') || dates[this.language].format || DPGlobal.getDefaultFormat(this.formatType, 'input'), this.formatType);
4343
this.isInline = false;
4444
this.isVisible = false;
4545
this.isInput = this.element.is('input');

‎js/locales/bootstrap-datetimepicker.pt-BR.js

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
*/
55
;(function($){
66
$.fn.datetimepicker.dates['pt-BR'] = {
7+
format: 'dd/mm/yyyy',
78
days: ["Domingo", "Segunda", "Terça", "Quarta", "Quinta", "Sexta", "Sábado", "Domingo"],
89
daysShort: ["Dom", "Seg", "Ter", "Qua", "Qui", "Sex", "Sáb", "Dom"],
910
daysMin: ["Do", "Se", "Te", "Qu", "Qu", "Se", "Sa", "Do"],

0 commit comments

Comments
 (0)