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

部分日期dateFromString格式化出来date=nil #80

Open
GoodLuckBobe opened this issue Oct 21, 2019 · 3 comments
Open

部分日期dateFromString格式化出来date=nil #80

GoodLuckBobe opened this issue Oct 21, 2019 · 3 comments

Comments

@GoodLuckBobe
Copy link

No description provided.

@GoodLuckBobe
Copy link
Author

当使用时间选择器是默认日期使用1949-05-01(不止这个日期)时,切换日期会因为时区的问题导致无法选中默认日期

  • (NSDate *)br_getDate:(NSString *)dateString format:(NSString *)format {
    NSDateFormatter dateFormatter = [[NSDateFormatter alloc] init];
    dateFormatter.locale = [NSLocale currentLocale];
    /

    //设置转换后的目标日期时区
    NSTimeZone *toTimeZone = [NSTimeZone localTimeZone];
    //转换后源日期与世界标准时间的偏移量
    NSInteger toGMTOffset = [toTimeZone secondsFromGMTForDate:[NSDate date]];

    dateFormatter.timeZone = [NSTimeZone timeZoneForSecondsFromGMT:toGMTOffset];
    */
    dateFormatter.timeZone = [NSTimeZone localTimeZone];
    dateFormatter.dateFormat = format;
    NSDate *destDate = [dateFormatter dateFromString:dateString];

    return destDate;
    }
    BRErrorLog(@"参数格式错误!参数 defaultSelValue 的正确格式是:%@", self.selectDateFormatter);
    NSAssert(defaultSelDate, @"参数格式错误!请检查形参 defaultSelValue 的格式");

@agiapp
Copy link
Owner

agiapp commented Oct 22, 2019

👍非常感谢!👍,已修复!😊

@isdotjim
Copy link

搭个车...
想邀请Repo作者来w3c.group创建项目的对应小组。w3c.group是类似知识星球的社群工具,小组可设置为付费且有赞助功能,同时也是一个区块链主导的创作者社区。这是相关介绍:
http://t.cn/Ai1vLcCU
http://t.cn/Ai1vLcCG
http://t.cn/Ai1vLcCA

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

No branches or pull requests

3 participants