1010 *
1111 */
1212
13- import { toDate1 , getDateWithNewTimezone , getStrTimezone , getLocalTimezone } from '@opentiny/utils'
13+ import { toDate1 , getDateWithNewTimezone , getStrTimezone , getLocalTimezone , paeseIso8601 } from '@opentiny/utils'
1414import { isNumber , isDate } from '@opentiny/utils'
1515import { userPopper } from '@opentiny/vue-hooks'
1616import { DATEPICKER } from '@opentiny/utils'
@@ -172,6 +172,28 @@ export const parseAsFormatAndType =
172172 return parser ( value , format , rangeSeparator )
173173 }
174174
175+ const ignoreTimezone = ( value ) => {
176+ let res = value
177+
178+ const ignoreTimezoneFn = ( value ) => {
179+ let date = value
180+ const iso8601 = paeseIso8601 ( value )
181+ if ( iso8601 ) {
182+ const { year, month, day, hours, minutes, seconds } = iso8601
183+ date = new Date ( year , month , day , hours , minutes , seconds )
184+ }
185+ return date
186+ }
187+
188+ if ( Array . isArray ( res ) ) {
189+ res = res . map ( ( item ) => ignoreTimezoneFn ( item ) )
190+ } else {
191+ res = ignoreTimezoneFn ( res )
192+ }
193+
194+ return res
195+ }
196+
175197export const parsedValue =
176198 ( { api, props, state, t } ) =>
177199 ( ) => {
@@ -191,18 +213,18 @@ export const parsedValue =
191213 return props . modelValue
192214 }
193215
216+ let value = ignoreTimezone ( props . modelValue )
217+
194218 if ( state . valueFormat ) {
195- let date = props . modelValue
219+ let date = value
196220
197- if ( isServiceTimezone ) {
198- if ( Array . isArray ( date ) ) {
199- date = [ ] . concat ( date ) . map ( ( item ) => {
200- return isDate ( item ) ? formatDate ( item , state . valueFormat , t ) : item
201- } )
202- } else {
203- if ( state . valueFormat !== DATEPICKER . TimesTamp ) {
204- date = formatDate ( date , state . valueFormat , t )
205- }
221+ if ( Array . isArray ( date ) ) {
222+ date = [ ] . concat ( date ) . map ( ( item ) => {
223+ return isDate ( item ) ? formatDate ( item , state . valueFormat , t ) : item
224+ } )
225+ } else {
226+ if ( state . valueFormat !== DATEPICKER . TimesTamp && isDate ( date ) ) {
227+ date = formatDate ( date , state . valueFormat , t )
206228 }
207229 }
208230 const result = api . parseAsFormatAndType ( date , state . valueFormat , state . type , props . rangeSeparator )
0 commit comments