33</template >
44
55<script >
6- import moment from ' moment'
7-
86export default {
97 props: {
108 field: {type: String , default: ' ' },
@@ -44,11 +42,14 @@ export default {
4442 }
4543 switch (this .type ) {
4644 case ' datetick' :
47- return moment (text, ' YYYY-MM-DD' ).valueOf ()
45+ // return moment(text, 'YYYY-MM-DD').valueOf()
46+ return new Date (text + ' GMT+0' ).getTime ()
4847 case ' datetimetick' :
49- return moment (text, ' YYYY-MM-DD HH:mm' ).valueOf ()
48+ // return moment(text, 'YYYY-MM-DD HH:mm').valueOf()
49+ return new Date (text + ' GMT+0' ).getTime ()
5050 case ' datetimesectick' :
51- return moment (text, ' YYYY-MM-DD HH:mm:ss' ).valueOf ()
51+ // return moment(text, 'YYYY-MM-DD HH:mm:ss').valueOf()
52+ return new Date (text + ' GMT+0' ).getTime ()
5253 case ' check10' :
5354 case ' checkYN' :
5455 case ' checkTF' :
@@ -70,17 +71,21 @@ export default {
7071 default (val ) {
7172 // § magic to hide the temp key
7273 if (this .keyField && val && val .toString ().startsWith (' §' )) return ' '
73-
74+ const offset = new Date (). getTimezoneOffset () * 60 * 1000
7475 switch (this .type ) {
7576 case ' date' :
76- return val? moment (val).format (' YYYY-MM-DD' ): ' '
77+ // return val? moment(val).format('YYYY-MM-DD'): ''
78+ return val? new Date (new Date (val) - offset).toISOString ().slice (0 , 10 ) : ' '
7779 case ' datetick' :
78- return val? moment (Number (val)).format (' YYYY-MM-DD' ): ' '
80+ // return val? moment(Number(val)).format('YYYY-MM-DD'): ''
81+ return val? new Date (Number (val) - offset).toISOString ().slice (10 ) : ' '
7982 case ' datetimetick' :
80- return val? moment (Number (val)).format (' YYYY-MM-DD HH:mm' ): ' '
83+ // return val? moment(Number(val)).format('YYYY-MM-DD HH:mm'): ''
84+ return val? new Date (Number (val) - offset).toISOString ().replace (' T' , ' ' ).slice (0 , 16 ) : ' '
8185 case ' datetimesectick' :
82- if (! val) return ' '
83- return val? moment (Number (val)).format (' YYYY-MM-DD HH:mm:ss' ): ' '
86+ // if (!val) return ''
87+ // return val? moment(Number(val)).format('YYYY-MM-DD HH:mm:ss'): ''
88+ return val? new Date (Number (val) - offset).toISOString ().replace (' T' , ' ' ).slice (0 , 19 ) : ' '
8489 case ' map' :
8590 if (this .options .constructor .name .endsWith (' Function' ))
8691 return this .options (val)[val]
@@ -113,23 +118,26 @@ export default {
113118 allowKeys = allowKeys || [' 0' , ' 1' , ' 2' , ' 3' , ' 4' , ' 5' , ' 6' , ' 7' , ' 8' , ' 9' , ' -' ]
114119 if (! validate) validate = (val ) => {
115120 if (val === ' ' ) return ' '
116- if (! moment (val, ' YYYY-MM-DD' , true ).isValid ()) return this .$parent .localizedLabel .invalidInputValue
121+ // if (!moment(val, 'YYYY-MM-DD', true).isValid()) return this.$parent.localizedLabel.invalidInputValue
122+ if (! / ^ \d {4} -\d {2} -\d {2} $ / .test (val)) return this .$parent .localizedLabel .invalidInputValue
117123 return ' '
118124 }
119125 break
120126 case ' datetime' :
121127 allowKeys = allowKeys || [' 0' , ' 1' , ' 2' , ' 3' , ' 4' , ' 5' , ' 6' , ' 7' , ' 8' , ' 9' , ' -' , ' ' , ' :' ]
122128 if (! validate) validate = (val ) => {
123129 if (val === ' ' ) return ' '
124- if (! moment (val, ' YY-MM-DD hh:mm' , true ).isValid ()) return this .$parent .localizedLabel .invalidInputValue
130+ // if (!moment(val, 'YY-MM-DD hh:mm', true).isValid()) return this.$parent.localizedLabel.invalidInputValue
131+ if (! / ^ \d {4} -\d {2} -\d {2} \d {2} :\d {2} $ / .test (val)) return this .$parent .localizedLabel .invalidInputValue
125132 return ' '
126133 }
127134 break
128135 case ' datetimesec' :
129136 allowKeys = allowKeys || [' 0' , ' 1' , ' 2' , ' 3' , ' 4' , ' 5' , ' 6' , ' 7' , ' 8' , ' 9' , ' -' , ' ' , ' :' ]
130137 if (! validate) validate = (val ) => {
131138 if (val === ' ' ) return ' '
132- if (! moment (val, ' YY-MM-DD hh:mm:ss' , true ).isValid ()) return this .$parent .localizedLabel .invalidInputValue
139+ // if (!moment(val, 'YY-MM-DD hh:mm:ss', true).isValid()) return this.$parent.localizedLabel.invalidInputValue
140+ if (! / ^ \d {4} -\d {2} -\d {2} \d {2} :\d {2} :\d {2} $ / .test (val)) return this .$parent .localizedLabel .invalidInputValue
133141 return ' '
134142 }
135143 break
0 commit comments