Skip to content

Commit 2d45d98

Browse files
hastommarcosmoura
authored andcommitted
refactor(MdDatepicker): upgrade date-fns (#2037)
1 parent 67677a2 commit 2d45d98

File tree

7 files changed

+20
-19
lines changed

7 files changed

+20
-19
lines changed

docs/app/pages/Components/Datepicker/examples/BasicDatepicker.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
<md-field>
1313
<label for="movie">Date format</label>
1414
<md-select v-model="dateFormat">
15-
<md-option value="YYYY-MM-DD">default</md-option>
16-
<md-option value="YYYY/MM/DD">YYYY/MM/DD</md-option>
17-
<md-option value="DD/MM/YYYY">DD/MM/YYYY</md-option>
18-
<md-option value="MM/DD/YYYY">MM/DD/YYYY</md-option>
15+
<md-option value="yyyy-MM-dd">default</md-option>
16+
<md-option value="yyyy/MM/dd">yyyy/MM/dd</md-option>
17+
<md-option value="dd/MM/yyyy">dd/MM/yyyy</md-option>
18+
<md-option value="MM/dd/yyyy">MM/dd/yyyy</md-option>
1919
</md-select>
2020
<span class="md-helper-text">This config is global.</span>
2121
</md-field>

docs/app/pages/Components/Datepicker/examples/MultiTypesDatepicker.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
export default {
4747
name: 'MultiTypesDatepicker',
4848
data () {
49-
let dateFormat = this.$material.locale.dateFormat || 'YYYY-MM-DD'
49+
let dateFormat = this.$material.locale.dateFormat || 'yyyy-MM-dd'
5050
let now = new Date()
5151
5252
return {
@@ -82,7 +82,7 @@
8282
}
8383
},
8484
dateFormat () {
85-
return this.$material.locale.dateFormat || 'YYYY-MM-DD'
85+
return this.$material.locale.dateFormat || 'yyyy-MM-dd'
8686
},
8787
mdType () {
8888
switch (this.mdTypeValue) {

docs/app/pages/Configuration.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@
88
import Vue from 'vue'
99

1010
// change single option
11-
Vue.material.locale.dateFormat = 'DD/MM/YYYY'
11+
Vue.material.locale.dateFormat = 'dd/MM/yyyy'
1212

1313
// change multiple options
1414
Vue.material = {
1515
...Vue.material,
1616
locale: {
1717
...Vue.material.locale,
18-
dateFormat: 'DD/MM/YYYY',
18+
dateFormat: 'dd/MM/yyyy',
1919
firstDayOfAWeek: 1
2020
}
2121
}
@@ -51,7 +51,7 @@
5151
endYear: 2099,
5252

5353
// date format for date picker
54-
dateFormat: 'YYYY-MM-DD',
54+
dateFormat: 'yyyy-MM-dd',
5555

5656
// i18n strings
5757
days: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
"css-loader": "^0.28.9",
6767
"css-mqpacker": "^6.0.2",
6868
"cz-conventional-changelog": "^2.1.0",
69-
"date-fns": "^2.0.0-alpha.7",
69+
"date-fns": "^2.0.0-alpha.27",
7070
"deepmerge": "^2.0.1",
7171
"eslint": "^4.16.0",
7272
"eslint-config-standard": "^11.0.0-beta.0",

src/components/MdDatepicker/MdDatepicker.vue

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
: 'date'
8585
},
8686
dateFormat () {
87-
return this.locale.dateFormat || 'YYYY-MM-DD'
87+
return this.locale.dateFormat || 'yyyy-MM-dd'
8888
},
8989
modelType () {
9090
if (this.isModelTypeString) {
@@ -120,12 +120,12 @@
120120
return parsedDate && isValid(parsedDate) ? parsedDate : null
121121
},
122122
pattern () {
123-
return this.dateFormat.replace(/YYYY|MM|DD/g, match => {
123+
return this.dateFormat.replace(/yyyy|MM|dd/g, match => {
124124
switch (match) {
125-
case 'YYYY':
125+
case 'yyyy':
126126
return '[0-9]{4}'
127127
case 'MM':
128-
case 'DD':
128+
case 'dd':
129129
return '[0-9]{2}'
130130
}
131131
})
@@ -172,7 +172,7 @@
172172
},
173173
dateFormat () {
174174
if (this.localDate) {
175-
this.inputDate = format(this.inputDate, this.dateFormat)
175+
this.inputDate = format(this.localDate, this.dateFormat)
176176
}
177177
}
178178
},

src/material.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const init = () => {
99
locale: {
1010
startYear: 1900,
1111
endYear: 2099,
12-
dateFormat: 'YYYY-MM-DD',
12+
dateFormat: 'yyyy-MM-dd',
1313
days: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],
1414
shortDays: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
1515
shorterDays: ['S', 'M', 'T', 'W', 'T', 'F', 'S'],

yarn.lock

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2696,9 +2696,10 @@ datauri@^1.1.0:
26962696
mimer "^0.3.2"
26972697
semver "^5.5.0"
26982698

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

27032704
date-now@^0.1.4:
27042705
version "0.1.4"

0 commit comments

Comments
 (0)