-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
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
✨ Calendar & initial impl for Matsudo #6
base: master
Are you sure you want to change the base?
Conversation
@tomo1560 コメント追加しました |
今月分テストで回してみたけど3月17日から3月23日がバグってるかな
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
レビューしました
お時間がある時にご確認をお願いいたします
fn main() { | ||
println!("Hello, world!"); | ||
let calendar = calendar::matsudo::Matsudo::new(Weekday::Thu); | ||
let today = Local.ymd(2021, 3, 17).and_hms(0, 0, 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
日付だけ見て処理するのであればDateTimeじゃなくてDateで処理した方がいいかも
$other_plastic => Some(Gomi::new("その他のプラスチックなどのごみ")), | ||
_ => None, | ||
}, | ||
if (week_num_by_weekday($current_time, $glass_week_day) == $glass_week_num) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
第何週目しか見てなくて陶磁器・ガラスなどのごみの週に全て「陶磁器・ガラスなどのゴミ」が入っちゃってそう
} | ||
} | ||
|
||
fn week_num_by_weekday(time: DateTime<Local>, weekday: Weekday) -> u32 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
今日が月の第何週目を求めるなら、一年における経過した週から今月までに経過した週を引いた方がスッキリするかも
fn week_num_by_weekday2(time: Date<Local>) -> u32 {
time.iso_week().week() - time.with_day0(0).unwrap().iso_week().week() + 1
}
#[cfg(test)]
mod tests {
use chrono::{Local, TimeZone};
use crate::calendar::matsudo::week_num_by_weekday2;
#[test]
fn week_num_3_17() {
let date = Local.ymd(2021,3,17);
assert_eq!(week_num_by_weekday2(date), 3);
}
#[test]
fn week_num_1_1() {
let date = Local.ymd(2021,1,1);
assert_eq!(week_num_by_weekday2(date), 1);
}
#[test]
fn week_num_12_31() {
let date = Local.ymd(2021,12,31);
assert_eq!(week_num_by_weekday2(date), 5);
}
#[test]
fn week_num_2020_2_29() {
let date = Local.ymd(2020,2,29);
assert_eq!(week_num_by_weekday2(date), 5);
}
}
Closes #2