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
No description provided.
The text was updated successfully, but these errors were encountered:
inDays: { get: () => (this._duration / Duration.microsecondsPerDay) >> 0, }, inHours: { get: () => (this._duration / Duration.microsecondsPerHour) >> 0, }, inMinutes: { get: () => (this._duration / Duration.microsecondsPerMinute) >> 0, }, inSeconds: { get: () => (this._duration / Duration.microsecondsPerSecond) >> 0, }, inMilliseconds: { get: () => (this._duration / Duration.microsecondsPerMillisecond) >> 0, },
这里 >> 0的目的看起来是想向下取整,但是 inMilliseconds 很容易就超出位运算上限。 我不是很懂JS,但是我看了一下说是JS的位运算都是32位的,所以这里很有可能出现问题。例如我在dart中写: DateTime.now().subtract(Duration(days: 30)); 时间跨度的计算,我看JS代码里头是以毫秒来计算的,30天得到的毫秒代码里是用(微秒/1000) >> 0得来的,除完之后再做位运算,推测已经到达位数上限,导致算出来的值有问题。
是不是用Math.floor比较好一点?
Sorry, something went wrong.
No branches or pull requests
No description provided.
The text was updated successfully, but these errors were encountered: