This repository was archived by the owner on Sep 27, 2023. It is now read-only.
Merged
Conversation
akiomik
commented
Jan 7, 2022
| const month = parseInt(matches[2], 10) | ||
| const day = parseInt(matches[3], 10) | ||
| return new DateParam(new Date(year, month, day)) | ||
| return new DateParam(new Date(str)) |
Contributor
Author
There was a problem hiding this comment.
バグ修正の本体です。2つのバグがありました。
new Date()の引数はnew Date(year, month, day)ではなくnew Date(year, monthIndex, day)なので、指定月-1を渡すのが正しいのだが、そのまま月を渡していたnew Date(year, monthIndex, day)形式でDateを生成すると自動的にタイムゾーンがGMT+0900 (Japan Standard Time)として解釈されるものの、toISOString()時にT15:00:00.000ZとUTCに自動的に変換されてしまうために、ロケールが日本の場合には-1日されて解釈されてしまう (?)
上記の問題はどちらも new Date('YYYY-MM-DD') のように文字列型で渡すことで解決したので、そのようにしています。
参考: https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/Date/Date
Contributor
There was a problem hiding this comment.
文字列渡すほうがむしろ安全っていうのがちょい残念だけど、なるほど。
真ん中が monthIndex だったの、見るたびに「あーそうだった」ってなるな・・・
shoe116
approved these changes
Jan 7, 2022
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
以下のバグを修正します。
BCODE(ticker, day, prop)を実行したときのdayが意図しない日付に解釈されてしまうバグを修正