fix: use naivedate for zodiac signs
This commit is contained in:
parent
63dbe9c20c
commit
228f7129d1
|
@ -12,7 +12,7 @@ use axum::http::StatusCode;
|
|||
use axum::routing::{get, post};
|
||||
use axum::{Router, Json};
|
||||
use axum::extract::{State, Path};
|
||||
use chrono::{NaiveDate, Utc, TimeZone, Datelike, Duration};
|
||||
use chrono::{NaiveDate, Utc, Datelike, Duration};
|
||||
use rand::distributions::{Alphanumeric, DistString};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use sqlx::PgPool;
|
||||
|
@ -455,17 +455,6 @@ async fn stat_breakdown(
|
|||
match &stat {
|
||||
Breakdown::Age => {
|
||||
for rec in records {
|
||||
// let date = match NaiveDate::parse_from_str(&rec.key, "%Y-%m-%d")
|
||||
// .ok()
|
||||
// .and_then(|date| date.and_hms_opt(0, 0, 0))
|
||||
// .map(|date| Utc.from_utc_datetime(&date))
|
||||
// {
|
||||
// Some(d) => d,
|
||||
// None => continue,
|
||||
// };
|
||||
|
||||
// let age = question.publish_date - date;
|
||||
// let years = age.num_days() / 365;
|
||||
let years: u32 = match rec.key.parse() {
|
||||
Ok(y) => y,
|
||||
Err(_) => continue,
|
||||
|
@ -490,13 +479,8 @@ async fn stat_breakdown(
|
|||
}
|
||||
Breakdown::ZodiacSign => {
|
||||
for rec in records {
|
||||
let date = match NaiveDate::parse_from_str(&rec.key, "%Y-%m-%d")
|
||||
.ok()
|
||||
.and_then(|date| date.and_hms_opt(0, 0, 0))
|
||||
.map(|date| Utc.from_utc_datetime(&date))
|
||||
{
|
||||
Some(d) => d,
|
||||
None => continue,
|
||||
let Ok(date) = NaiveDate::parse_from_str(&rec.key, "%Y-%m-%d") else {
|
||||
continue;
|
||||
};
|
||||
|
||||
let birthday = (date.month() * 100) + date.day();
|
||||
|
|
Loading…
Reference in New Issue