Skip to content

Commit 2bdf04d

Browse files
committed
[fix] time-picker: format ignore case
1 parent cbbc3e9 commit 2bdf04d

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/common/lang/date.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const DAY_TIMESTAMP = 60 * 60 * 24 * 1000
22
const HOUR_TIMESTAMP = 60 * 60 * 1000
33
const MINUTE_TIMESTAMP = 60 * 1000
44

5-
function formatType(type, format, value, attributes) {
5+
function formatType(type, format, value, regExpAttributes) {
66
const regExpMap = {
77
year: '(Y+)',
88
month: '(M+)',
@@ -14,7 +14,7 @@ function formatType(type, format, value, attributes) {
1414
millisecond: '(S)'
1515
}
1616

17-
if (new RegExp(regExpMap[type], attributes).test(format)) {
17+
if (new RegExp(regExpMap[type], regExpAttributes).test(format)) {
1818
const replaceStr = type === 'year'
1919
? value.toString().substr(4 - RegExp.$1.length)
2020
: (RegExp.$1.length === 1) ? value : pad(value)
@@ -28,7 +28,7 @@ function pad(value) {
2828
return ('00' + value).substr(('' + value).length)
2929
}
3030

31-
function formatDate(date, format) {
31+
function formatDate(date, format, regExpAttributes) {
3232
const map = {
3333
year: date.getFullYear(),
3434
month: date.getMonth() + 1,
@@ -41,7 +41,7 @@ function formatDate(date, format) {
4141
}
4242

4343
for (const key in map) {
44-
format = formatType(key, format, map[key])
44+
format = formatType(key, format, map[key], regExpAttributes)
4545
}
4646

4747
return format

src/components/time-picker/time-picker.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@
194194
} else {
195195
days.push({
196196
value: timestamp,
197-
text: formatDate(new Date(timestamp), dayConf.format)
197+
text: formatDate(new Date(timestamp), dayConf.format, 'i')
198198
})
199199
}
200200
}

0 commit comments

Comments
 (0)