Skip to content
This repository was archived by the owner on Sep 27, 2023. It is now read-only.

Add PeriodParser#48

Merged
shoe116 merged 2 commits intodevelopmentfrom
add-period-parser
Nov 8, 2021
Merged

Add PeriodParser#48
shoe116 merged 2 commits intodevelopmentfrom
add-period-parser

Conversation

@akiomik
Copy link
Copy Markdown
Contributor

@akiomik akiomik commented Nov 6, 2021

No description provided.

@akiomik akiomik requested a review from shoe116 November 6, 2021 03:53
@akiomik akiomik self-assigned this Nov 6, 2021
Copy link
Copy Markdown
Contributor

@shoe116 shoe116 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

日付のParseのしかただけちょっと気になりました

Comment on lines +27 to +30
str = str.toLowerCase()
if (str == 'latest') {
return new DateParam(str)
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

なるほど ま、設定値に切り出すほどでもないか

Comment on lines +32 to +35
const matches = str.match(/^(\d{4})-(\d{2})-(\d{2})$/)
if (matches == undefined) {
throw new ParseError(`Invalid date format: ${str}`)
}
Copy link
Copy Markdown
Contributor

@shoe116 shoe116 Nov 7, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

あー これ自前でvalidation する?直接 Date.parse して例外処理っていうのもありだと思うけど。

実行環境毎に Date.parse の挙動が違うとかそういうのを想定してる?

Copy link
Copy Markdown
Contributor Author

@akiomik akiomik Nov 8, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

jsの new Date(str) はいろんなフォーマットでパースできてしまうので、将来的に別のフォーマットを追加した際に挙動が変わってしまう懸念があり、なるべくフォーマットは固定化した方がいいと思っています
(例えば年次ごとの値を取得するエンドポイントが追加されたとき、 BCODE(ticker, 2020, propName) みたいな関数呼び出しの口になると、 new Date('2020') のパースと = 2020-01-01 と衝突してしまう)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

なるほど

@shoe116 shoe116 merged commit eac6568 into development Nov 8, 2021
@akiomik akiomik deleted the add-period-parser branch November 10, 2021 06:59
@akiomik akiomik mentioned this pull request Nov 19, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants