Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get gregorian value as SelectedDate #2

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
14 changes: 12 additions & 2 deletions js/persianDatepicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
dowTitle: ["شنبه", "یکشنبه", "دوشنبه", "سه شنبه", "چهارشنبه", "پنج شنبه", "جمعه"],
shortDowTitle: ["ش", "ی", "د", "س", "چ", "پ", "ج"],
showGregorianDate: !1,
hasGregorianDate: !1,
persianNumbers: !0,
formatDate: "YYYY/MM/DD",
selectedBefore: !1,
Expand Down Expand Up @@ -75,12 +76,20 @@
var patt1 = new RegExp('^([1-9][0-9][0-9][0-9])/([0]?[1-9]|[1][0-2])/([0]?[1-9]|[1-2][0-9]|[3][0-1])$');
if (el.is('input')) {
if (patt1.test(el.val()))
self.options.selectedDate = el.val();
self.options.selectedDate = el.val();
} else {
if (patt1.test(el.html()))
self.options.selectedDate = el.html();
}
}
if(self.options.hasGregorianDate){
self.options.selectedDate = self.jDateFunctions.getPCalendarDate(this.jDateFunctions.getJulianDay(new Date(self.options.selectedDate))).toString(options.formatDate)
if (el.is('input')) {
el.val(self.options.selectedDate);
} else {
el.html(self.options.selectedDate);
}
}
self._persianDate = (self.options.selectedDate != undefined) ? new persianDate().parse(self.options.selectedDate) : self.now();
if (options.selectableYears != undefined && options.selectableYears._indexOf(self._persianDate.year) == -1)
self._persianDate.year = options.selectableYears[0];
Expand Down Expand Up @@ -400,6 +409,7 @@
el.html(self.persianDate.parse(v).toString(self.options.formatDate));
}
el.data('date', { jDate: v, gDate: this.jDateFunctions.getGDate(this.persianDate)._toString("YYYY/MM/DD/DW") });
el.data('gregorian',self.persianDate.parse(v).gDate._toString(self.options.formatDate));
this.options.onSelect();
},
getDate: function (jd, d) {
Expand All @@ -409,7 +419,7 @@
},
now: function () {
return this.jDateFunctions.getPCalendarDate(this.jDateFunctions.getJulianDay(new Date()));
},
}
};
// Return the persianDatepicker plugin
return persianDatepicker;
Expand Down
14 changes: 0 additions & 14 deletions js/persianDatepicker.min.js

This file was deleted.