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

fix(uni-datetime-picker):修复uni-datetime-picker在 iOS 微信小程序上type='daterange'时,传入'YYYY-MM-DD'格式不生效的问题 #965

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ddx2019
Copy link

@ddx2019 ddx2019 commented Oct 29, 2024

No description provided.

@ddx2019
Copy link
Author

ddx2019 commented Oct 29, 2024

@GRCmade

现象

uni-datetime-picker在 iOS 微信小程序上type='daterange'时,选中日期范围后,只会返回今日日期。

排查过程

下面四行代码中的模板字符串直接使用了时间 this.tempRange.startTimethis.tempRange.endTime ,并未做this.hasTime的判断。

当时间 this.tempRange.startTimethis.tempRange.endTime为空字符串时,在调用dateCompare方法时传入fixIosDateFormat方法的value的格式为'YYYY-MM-DD '(最后多出一个空格),导致正则匹配失效而无法实现格式替换,从而无法兼容iOS的new Date入参格式。

if (this.start && !dateCompare(this.start, `${this.tempRange.startDate} ${this.tempRange.startTime}`)) {

if (this.start && !dateCompare(this.start, `${this.tempRange.endDate} ${this.tempRange.endTime}`)) {

if (this.end && !dateCompare(`${this.tempRange.startDate} ${this.tempRange.startTime}`, this.end)) {

if (this.end && !dateCompare(`${this.tempRange.endDate} ${this.tempRange.endTime}`, this.end)) {

修复方式

加入this.hasTime的判断,以确保正确传入日期时间格式。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant