Skip to content
This repository has been archived by the owner on Apr 6, 2023. It is now read-only.

Allows use of an array of date formats #54

Merged
merged 4 commits into from
Jul 1, 2014
Merged
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
12 changes: 10 additions & 2 deletions moment-datepicker/moment-datepicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,11 @@
return (this.moment && this.moment.clone());
},
getAsText: function (format) {
return (this.moment && this.moment.format(format || this.format)) || '';
var displayFormat = this.format;
if (Object.prototype.toString.call(displayFormat) === '[object Array]') {
displayFormat = displayFormat[0];
}
return (this.moment && this.moment.format(format || displayFormat)) || '';
},
show: function (e) {

Expand Down Expand Up @@ -473,7 +477,11 @@
parseDate: function (value, format) {
var mmnt = null;
if (typeof value === "string") {
mmnt = moment(value, format);
if (Object.prototype.toString.call(format) === '[object Array]') {
mmnt = moment(value, format, true);
} else {
mmnt = moment(value, format);
}
}
if (!mmnt || !mmnt.isValid()) {
mmnt = moment(value);
Expand Down