We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
复现
new Date('2020-07-22T10:54:14.000+0000'); // 解析失败 new Date('2020/07/22 10:54:14'); // 格式化后正确解析 // 原因: 时间字符串中的 '-' 在部分 IOS 设备上无法兼容,需要替换为'/'的标准格式 const date = new Date(timeStr.replace(/-/g, '/'));
解决方案
const formatTimeByDateStr = (dateStr) => { let date = getDateFormISO8601(dateStr); const year = date.getFullYear(); const month = date.getMonth() + 1; const day = date.getDate(); const hour = date.getHours(); const minute = date.getMinutes(); const second = date.getSeconds(); return ( [year, month, day].map(formatNumber).join('-') + ' ' + [hour, minute, second].map(formatNumber).join(':') ); }; const getDateFormISO8601 = (dateStr) => { // 修改 new Date(ISO 8601 时间,eg: 2020-07-22T10:54:14.000+0000)为 ios 支持的 2020/07/22 10:54:14 const replace = (str) => { console.log(str); let date = str.slice(0, 10).replace(/-/g, '/'); let time = str.slice(11, 19); let res = date + ' ' + time; return res; }; let timeStr = replace(dateStr); let date = new Date(timeStr); // 修正时间偏移量 8 小时 2020/07/22 18:54:14 date.setHours(date.getHours() + 8); return date; };
将 node-sass 转换为 dart-sass,解决 node-sass 安装困难症。
升级方式如下:
npm uninstall node-sass npm install sass -S -D
The text was updated successfully, but these errors were encountered:
No branches or pull requests
目录
1. IOS 设备无法正确解析 ISO 8601 时间格式
复现
解决方案
2. Node Sass to Dart Sass
将 node-sass 转换为 dart-sass,解决 node-sass 安装困难症。
升级方式如下:
参考
The text was updated successfully, but these errors were encountered: