-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
22 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
/** | ||
* cxCalendar | ||
* @version 3.0.2 | ||
* @version 3.0.3 | ||
* @author ciaoca | ||
* @email [email protected] | ||
* @site https://github.com/ciaoca/cxCalendar | ||
|
@@ -182,9 +182,10 @@ theTool.parseDate = function(value, mustDef) { | |
}; | ||
|
||
// 格式化日期值 | ||
theTool.formatDate = function(style, time) { | ||
theTool.formatDate = function(style, time, lang) { | ||
const self = this; | ||
const theDate = self.parseDate(time); | ||
const language = self.extend({}, cxCalendar.languages.default, lang); | ||
|
||
if (typeof style !== 'string' || !self.isDate(theDate)) { | ||
return time; | ||
|
@@ -207,7 +208,7 @@ theTool.formatDate = function(style, time) { | |
attr.h = self.fillLeadZero(attr.g, 2); | ||
attr.i = self.fillLeadZero(theDate.getMinutes(), 2); | ||
attr.s = self.fillLeadZero(theDate.getSeconds(), 2); | ||
attr.a = attr.G > 12 ? cacheApi.language.pm : cacheApi.language.am; | ||
attr.a = attr.G > 12 ? language.pm : language.am; | ||
|
||
const keys = ['timestamp', 'Y', 'y', 'm', 'n', 'd', 'j', 'W', 'H', 'h', 'G', 'g', 'i', 's', 'a']; | ||
const reg = new RegExp('(' + keys.join('|') + ')', 'g'); | ||
|
@@ -1504,7 +1505,7 @@ picker.prototype.getDate = function(style) { | |
newValue = []; | ||
break; | ||
} | ||
newValue.push(theTool.formatDate(style, theDate.getTime())); | ||
newValue.push(theTool.formatDate(style, theDate.getTime(), self.language)); | ||
} | ||
newValue = self.settings.mode === 'range' ? newValue.join(self.settings.rangeSymbol) : newValue.join(''); | ||
|
||
|
@@ -1541,7 +1542,7 @@ picker.prototype.setDate = function(value) { | |
} else if (theTime > self.maxDate.time) { | ||
theTime = self.maxDate.time; | ||
} | ||
newValue.push(theTool.formatDate(self.settings.format, theTime)); | ||
newValue.push(theTool.formatDate(self.settings.format, theTime, self.language)); | ||
} | ||
newValue = self.settings.mode === 'range' ? newValue.join(self.settings.rangeSymbol) : newValue.join(''); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
/** | ||
* cxCalendar | ||
* @version 3.0.2 | ||
* @version 3.0.3 | ||
* @author ciaoca | ||
* @email [email protected] | ||
* @site https://github.com/ciaoca/cxCalendar | ||
|
@@ -188,9 +188,10 @@ theTool.parseDate = function(value, mustDef) { | |
}; | ||
|
||
// 格式化日期值 | ||
theTool.formatDate = function(style, time) { | ||
theTool.formatDate = function(style, time, lang) { | ||
const self = this; | ||
const theDate = self.parseDate(time); | ||
const language = self.extend({}, cxCalendar.languages.default, lang); | ||
|
||
if (typeof style !== 'string' || !self.isDate(theDate)) { | ||
return time; | ||
|
@@ -213,7 +214,7 @@ theTool.formatDate = function(style, time) { | |
attr.h = self.fillLeadZero(attr.g, 2); | ||
attr.i = self.fillLeadZero(theDate.getMinutes(), 2); | ||
attr.s = self.fillLeadZero(theDate.getSeconds(), 2); | ||
attr.a = attr.G > 12 ? cacheApi.language.pm : cacheApi.language.am; | ||
attr.a = attr.G > 12 ? language.pm : language.am; | ||
|
||
const keys = ['timestamp', 'Y', 'y', 'm', 'n', 'd', 'j', 'W', 'H', 'h', 'G', 'g', 'i', 's', 'a']; | ||
const reg = new RegExp('(' + keys.join('|') + ')', 'g'); | ||
|
@@ -1510,7 +1511,7 @@ picker.prototype.getDate = function(style) { | |
newValue = []; | ||
break; | ||
} | ||
newValue.push(theTool.formatDate(style, theDate.getTime())); | ||
newValue.push(theTool.formatDate(style, theDate.getTime(), self.language)); | ||
} | ||
newValue = self.settings.mode === 'range' ? newValue.join(self.settings.rangeSymbol) : newValue.join(''); | ||
|
||
|
@@ -1547,7 +1548,7 @@ picker.prototype.setDate = function(value) { | |
} else if (theTime > self.maxDate.time) { | ||
theTime = self.maxDate.time; | ||
} | ||
newValue.push(theTool.formatDate(self.settings.format, theTime)); | ||
newValue.push(theTool.formatDate(self.settings.format, theTime, self.language)); | ||
} | ||
newValue = self.settings.mode === 'range' ? newValue.join(self.settings.rangeSymbol) : newValue.join(''); | ||
|
||
|
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "cxcalendar3", | ||
"version": "3.0.2", | ||
"version": "3.0.3", | ||
"description": "JavaScript date picker, support range, time, year, month.", | ||
"author": "ciaoca <[email protected]> (https://github.com/ciaoca/cxCalendar)", | ||
"license": "MIT", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters