Skip to content
This repository has been archived by the owner on Jun 1, 2023. It is now read-only.

getComplementedDate で本日の日付が去年のものとしてreturnされている #4693

Closed
MaySoMusician opened this issue Jun 3, 2020 · 3 comments · Fixed by #4708
Closed
Labels
bug バグ。本来あるべき動作をしていないもの good-first-issue 初心者や、バックグラウンドを知らない人でも取り組みやすいIssue

Comments

@MaySoMusician
Copy link
Contributor

MaySoMusician commented Jun 3, 2020

起こっている問題 / The Problem

  • getComplementedDate 関数は MM/DD 形式のように年情報が無い日付文字列からDateオブジェクトを生成するために、年情報を補完するためのもの。
  • 大まかには「 MM/DD 部分が今日より後だったら去年、それ以外の場合は今年とする」という処理内容
  • 詳細は 日付のフォーマットの多言語対応 #4232 (comment) を参照
    • 上記コメントで

      最新のデータは翌日以降に取得するので、現在と同じ日付のデータも去年のものと考えられる。

      とあるが 6月1日の次が1月6日になっている #4680 から推測するに当日中に取得されるデータも存在していた

期待する見せ方・挙動 / Expected Behavior

  • 上述の処理内容において「 MM/DD が本日(=実行したときの日付)と同じだったら今年とする」になるようにする

起こっている問題の再現手段 / Steps to Reproduce

現在発生してる問題は無し。

動作環境・ブラウザ / Environment

  • 依存なし
@MaySoMusician MaySoMusician added bug バグ。本来あるべき動作をしていないもの good-first-issue 初心者や、バックグラウンドを知らない人でも取り組みやすいIssue labels Jun 3, 2020
@goki90210
Copy link
Contributor

ここの
https://github.com/tokyo-metropolitan-gov/covid19/blob/6d630dcf7870ba712e9d62497fa572ed7c53f611/utils/formatDate.ts#L53-L67

特に
https://github.com/tokyo-metropolitan-gov/covid19/blob/6d630dcf7870ba712e9d62497fa572ed7c53f611/utils/formatDate.ts#L65-L67
が対象ですね。

 if (currentMonth < month || (currentMonth == month && currentDate < date)) { 
   targetYear -= 1 
 } 

でしょうか。

@MaySoMusician
Copy link
Contributor Author

@goki90210 そのような形で問題無いと思います。
currentMonth == monthcurrentMonth === month の方が良いかも)

@goki90210
Copy link
Contributor

@MaySoMusician ===にします。

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug バグ。本来あるべき動作をしていないもの good-first-issue 初心者や、バックグラウンドを知らない人でも取り組みやすいIssue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants