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

refactor(MdDatepicker): upgrade date-fns #2037

Merged
merged 1 commit into from
May 11, 2019
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
<md-field>
<label for="movie">Date format</label>
<md-select v-model="dateFormat">
<md-option value="YYYY-MM-DD">default</md-option>
<md-option value="YYYY/MM/DD">YYYY/MM/DD</md-option>
<md-option value="DD/MM/YYYY">DD/MM/YYYY</md-option>
<md-option value="MM/DD/YYYY">MM/DD/YYYY</md-option>
<md-option value="yyyy-MM-dd">default</md-option>
<md-option value="yyyy/MM/dd">yyyy/MM/dd</md-option>
<md-option value="dd/MM/yyyy">dd/MM/yyyy</md-option>
<md-option value="MM/dd/yyyy">MM/dd/yyyy</md-option>
</md-select>
<span class="md-helper-text">This config is global.</span>
</md-field>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
export default {
name: 'MultiTypesDatepicker',
data () {
let dateFormat = this.$material.locale.dateFormat || 'YYYY-MM-DD'
let dateFormat = this.$material.locale.dateFormat || 'yyyy-MM-dd'
let now = new Date()

return {
Expand Down Expand Up @@ -82,7 +82,7 @@
}
},
dateFormat () {
return this.$material.locale.dateFormat || 'YYYY-MM-DD'
return this.$material.locale.dateFormat || 'yyyy-MM-dd'
},
mdType () {
switch (this.mdTypeValue) {
Expand Down
6 changes: 3 additions & 3 deletions docs/app/pages/Configuration.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
import Vue from 'vue'

// change single option
Vue.material.locale.dateFormat = 'DD/MM/YYYY'
Vue.material.locale.dateFormat = 'dd/MM/yyyy'

// change multiple options
Vue.material = {
...Vue.material,
locale: {
...Vue.material.locale,
dateFormat: 'DD/MM/YYYY',
dateFormat: 'dd/MM/yyyy',
firstDayOfAWeek: 1
}
}
Expand Down Expand Up @@ -51,7 +51,7 @@
endYear: 2099,

// date format for date picker
dateFormat: 'YYYY-MM-DD',
dateFormat: 'yyyy-MM-dd',

// i18n strings
days: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
"css-loader": "^0.28.9",
"css-mqpacker": "^6.0.2",
"cz-conventional-changelog": "^2.1.0",
"date-fns": "^2.0.0-alpha.7",
"date-fns": "^2.0.0-alpha.27",
"deepmerge": "^2.0.1",
"eslint": "^4.16.0",
"eslint-config-standard": "^11.0.0-beta.0",
Expand Down
10 changes: 5 additions & 5 deletions src/components/MdDatepicker/MdDatepicker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
: 'date'
},
dateFormat () {
return this.locale.dateFormat || 'YYYY-MM-DD'
return this.locale.dateFormat || 'yyyy-MM-dd'
},
modelType () {
if (this.isModelTypeString) {
Expand Down Expand Up @@ -120,12 +120,12 @@
return parsedDate && isValid(parsedDate) ? parsedDate : null
},
pattern () {
return this.dateFormat.replace(/YYYY|MM|DD/g, match => {
return this.dateFormat.replace(/yyyy|MM|dd/g, match => {
switch (match) {
case 'YYYY':
case 'yyyy':
return '[0-9]{4}'
case 'MM':
case 'DD':
case 'dd':
return '[0-9]{2}'
}
})
Expand Down Expand Up @@ -172,7 +172,7 @@
},
dateFormat () {
if (this.localDate) {
this.inputDate = format(this.inputDate, this.dateFormat)
this.inputDate = format(this.localDate, this.dateFormat)
}
}
},
Expand Down
2 changes: 1 addition & 1 deletion src/material.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const init = () => {
locale: {
startYear: 1900,
endYear: 2099,
dateFormat: 'YYYY-MM-DD',
dateFormat: 'yyyy-MM-dd',
days: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],
shortDays: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
shorterDays: ['S', 'M', 'T', 'W', 'T', 'F', 'S'],
Expand Down
7 changes: 4 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2696,9 +2696,10 @@ datauri@^1.1.0:
mimer "^0.3.2"
semver "^5.5.0"

date-fns@^2.0.0-alpha.7:
version "2.0.0-alpha.11"
resolved "https://registry.yarnpkg.com/date-fns/-/date-fns-2.0.0-alpha.11.tgz#586e855107dc4717ba4d9f2c41cf12c3b72512c0"
date-fns@^2.0.0-alpha.27:
version "2.0.0-alpha.27"
resolved "https://registry.yarnpkg.com/date-fns/-/date-fns-2.0.0-alpha.27.tgz#5ecd4204ef0e7064264039570f6e8afbc014481c"
integrity sha512-cqfVLS+346P/Mpj2RpDrBv0P4p2zZhWWvfY5fuWrXNR/K38HaAGEkeOwb47hIpQP9Jr/TIxjZ2/sNMQwdXuGMg==

date-now@^0.1.4:
version "0.1.4"
Expand Down