Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
skyvow committed Aug 29, 2019
1 parent cadc163 commit a00bf1e
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 7 deletions.
11 changes: 10 additions & 1 deletion example/dist/date-picker-view/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,16 @@ function setMonth(date, month) {
}

function valueToDate(value, props = {}) {
if (!Array.isArray(value)) return new Date(value)
if (!Array.isArray(value)) {
if (typeof value === 'string') {
value = value.replace(/\-/g, '/')
}
if (!isNaN(Number(value))) {
value = Number(value)
}
return new Date(value)
}

const { mode, use12Hours } = props
const now = new Date()
const year = now.getFullYear()
Expand Down
10 changes: 5 additions & 5 deletions example/pages/date-picker-view/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
function getDateString(date = new Date) {
return {
year: date.getFullYear(),
month: date.getMonth(),
day: date.getDate(),
hour: date.getHours(),
minute: date.getMinutes(),
year: date.getFullYear() + '',
month: date.getMonth() + '',
day: date.getDate() + '',
hour: date.getHours() + '',
minute: date.getMinutes() + '',
}
}

Expand Down
11 changes: 10 additions & 1 deletion src/date-picker-view/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,16 @@ function setMonth(date, month) {
}

function valueToDate(value, props = {}) {
if (!Array.isArray(value)) return new Date(value)
if (!Array.isArray(value)) {
if (typeof value === 'string') {
value = value.replace(/\-/g, '/')
}
if (!isNaN(Number(value))) {
value = Number(value)
}
return new Date(value)
}

const { mode, use12Hours } = props
const now = new Date()
const year = now.getFullYear()
Expand Down

0 comments on commit a00bf1e

Please sign in to comment.