Changed all NaiveDateTimes to DateTime<Utc>
This commit is contained in:
parent
ac3dec3b18
commit
8aa1dd61d6
|
@ -1,4 +1,4 @@
|
|||
use chrono::{NaiveDateTime, Utc};
|
||||
use chrono::{Utc, DateTime};
|
||||
use rust_decimal::Decimal;
|
||||
use serde::{Serialize, Deserialize};
|
||||
|
||||
|
@ -7,8 +7,8 @@ use serde::{Serialize, Deserialize};
|
|||
pub struct Field {
|
||||
pub id: u32,
|
||||
pub place_id: u32,
|
||||
pub time_created: NaiveDateTime,
|
||||
pub last_updated: NaiveDateTime,
|
||||
pub time_created: DateTime<Utc>,
|
||||
pub last_updated: DateTime<Utc>,
|
||||
pub country: String,
|
||||
pub city: String,
|
||||
pub name: String,
|
||||
|
@ -19,6 +19,6 @@ pub struct Field {
|
|||
|
||||
impl Field {
|
||||
pub fn new() -> Field {
|
||||
Field { id: 0, place_id: 0, time_created: Utc::now().naive_utc(), last_updated: Utc::now().naive_utc(), country: "".to_string(), city: "".to_string(), name: "".to_string(), price_per_hour: Decimal::new(0, 0), currency: "".to_string(), description: None }
|
||||
Field { id: 0, place_id: 0, time_created: Utc::now(), last_updated: Utc::now(), country: "".to_string(), city: "".to_string(), name: "".to_string(), price_per_hour: Decimal::new(0, 0), currency: "".to_string(), description: None }
|
||||
}
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
use std::{fmt::Display, str::FromStr};
|
||||
|
||||
use chrono::{NaiveDateTime, Utc};
|
||||
use chrono::{Utc, DateTime};
|
||||
use err::Error;
|
||||
use serde::{Serialize, Deserialize};
|
||||
use rust_decimal::Decimal;
|
||||
|
@ -15,13 +15,13 @@ pub struct League {
|
|||
pub owner_id: u32,
|
||||
pub sport_id: u32,
|
||||
pub place_id: u32,
|
||||
pub time_created: NaiveDateTime,
|
||||
pub last_updated: NaiveDateTime,
|
||||
pub time_created: DateTime<Utc>,
|
||||
pub last_updated: DateTime<Utc>,
|
||||
/// State as in: Is the league open or closed? Not the geographical sense.
|
||||
pub state: String,
|
||||
pub visibility: String,
|
||||
/// When is the league happening?
|
||||
pub date_and_time: NaiveDateTime, //TODO: Switch from NaiveDateTime to TimeZones
|
||||
pub date_and_time: DateTime<Utc>, //TODO: Switch from DateTime<Utc> to TimeZones
|
||||
/// This will be stored as a Decimal in the database but the actual input from the user
|
||||
/// will not be in rust_decimal::Decimal type.
|
||||
pub cost_to_join: Decimal,
|
||||
|
@ -35,7 +35,7 @@ pub struct League {
|
|||
impl From<LeagueForCreationDto> for League {
|
||||
fn from(league_dto: LeagueForCreationDto) -> Self {
|
||||
Self {
|
||||
id: 0, owner_id: league_dto.user_id, sport_id: league_dto.sport_id, place_id:league_dto.place_id, time_created: Utc::now().naive_utc(), last_updated: Utc::now().naive_utc(), state: LeagueState::Open.to_string(),
|
||||
id: 0, owner_id: league_dto.user_id, sport_id: league_dto.sport_id, place_id:league_dto.place_id, time_created: Utc::now(), last_updated: Utc::now(), state: LeagueState::Open.to_string(),
|
||||
visibility: match league_dto.visibility {
|
||||
Some(visibility) => visibility.to_string(),
|
||||
None => LeagueVisibility::Public.to_string(),
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use chrono::{NaiveDateTime, Utc};
|
||||
use chrono::{Utc, DateTime};
|
||||
use serde::{Serialize, Deserialize};
|
||||
|
||||
use crate::dto::league_player::JoinRequest;
|
||||
|
@ -10,12 +10,12 @@ pub struct LeaguePlayer {
|
|||
pub id: u32,
|
||||
pub league_id: u32,
|
||||
pub player_id: u32,
|
||||
pub time_created: NaiveDateTime,
|
||||
pub last_updated: NaiveDateTime,
|
||||
pub time_created: DateTime<Utc>,
|
||||
pub last_updated: DateTime<Utc>,
|
||||
pub status: String
|
||||
}
|
||||
impl From<JoinRequest> for LeaguePlayer {
|
||||
fn from(join_req: JoinRequest) -> Self {
|
||||
Self { id: 0, league_id: join_req.league_id, player_id: join_req.user_id, time_created: Utc::now().naive_utc(), last_updated: Utc::now().naive_utc(), status: LeaguePlayerStatus::Requested.to_string() }
|
||||
Self { id: 0, league_id: join_req.league_id, player_id: join_req.user_id, time_created: Utc::now(), last_updated: Utc::now(), status: LeaguePlayerStatus::Requested.to_string() }
|
||||
}
|
||||
}
|
|
@ -1,11 +1,11 @@
|
|||
use chrono::{NaiveDateTime};
|
||||
use chrono::{Utc, DateTime};
|
||||
use serde::{Serialize, Deserialize};
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq, PartialOrd, Ord, Default)]
|
||||
pub struct Place{
|
||||
pub id: u32,
|
||||
pub time_created: NaiveDateTime,
|
||||
pub last_updated: NaiveDateTime,
|
||||
pub time_created: DateTime<Utc>,
|
||||
pub last_updated: DateTime<Utc>,
|
||||
pub name: String,
|
||||
pub sport_id: u32,
|
||||
pub country: String,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use chrono::{NaiveDateTime, Utc, NaiveDate};
|
||||
use chrono::{Utc, DateTime, NaiveDate};
|
||||
use serde::{Serialize, Deserialize};
|
||||
|
||||
use crate::dto::player::PlayerForCreationDto;
|
||||
|
@ -7,8 +7,8 @@ use crate::dto::player::PlayerForCreationDto;
|
|||
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq, PartialOrd, Ord, Default)]
|
||||
pub struct Player {
|
||||
pub id: u32,
|
||||
pub time_created: NaiveDateTime,
|
||||
pub last_updated: NaiveDateTime,
|
||||
pub time_created: DateTime<Utc>,
|
||||
pub last_updated: DateTime<Utc>,
|
||||
pub name: String,
|
||||
pub birth_date: NaiveDate,
|
||||
pub country: String,
|
||||
|
@ -22,7 +22,7 @@ pub struct Player {
|
|||
|
||||
impl From<PlayerForCreationDto> for Player {
|
||||
fn from(player_dto: PlayerForCreationDto) -> Self {
|
||||
Player { id: Default::default(), time_created: Utc::now().naive_utc(), last_updated: Utc::now().naive_utc(), name: player_dto.name.clone(), birth_date: player_dto.birth_date.clone(), country: player_dto.country.clone(), city: player_dto.city.clone(), identification_number: None, bio: None, profile_picture_url: None, id_verified: false, phone_number_verified: false }
|
||||
Player { id: Default::default(), time_created: Utc::now(), last_updated: Utc::now().with_timezone(&Utc), name: player_dto.name.clone(), birth_date: player_dto.birth_date.clone(), country: player_dto.country.clone(), city: player_dto.city.clone(), identification_number: None, bio: None, profile_picture_url: None, id_verified: false, phone_number_verified: false }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,7 @@ impl Player{
|
|||
self.city = "".to_string();
|
||||
self.id_verified = false;
|
||||
self.identification_number = None;
|
||||
self.last_updated = Utc::now().naive_utc();
|
||||
self.last_updated = Utc::now();
|
||||
self
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
use chrono::{NaiveDateTime, Utc};
|
||||
use chrono::{Utc, DateTime};
|
||||
use serde::{Serialize, Deserialize};
|
||||
|
||||
use crate::dto::trust::TrustRequestDto;
|
||||
|
@ -11,12 +11,12 @@ pub struct Trust {
|
|||
pub truster_id: u32,
|
||||
/// The player who is being trusted (recieving the trust request)
|
||||
pub trustee_id: u32,
|
||||
pub time_created: NaiveDateTime,
|
||||
pub last_updated: NaiveDateTime
|
||||
pub time_created: DateTime<Utc>,
|
||||
pub last_updated: DateTime<Utc>
|
||||
}
|
||||
|
||||
impl From<TrustRequestDto> for Trust {
|
||||
fn from(trust_dto: TrustRequestDto) -> Self {
|
||||
Trust { id: 0, truster_id: trust_dto.truster_id, trustee_id: trust_dto.trustee_id, time_created: Utc::now().naive_utc(), last_updated: Utc::now().naive_utc() }
|
||||
Trust { id: 0, truster_id: trust_dto.truster_id, trustee_id: trust_dto.trustee_id, time_created: Utc::now(), last_updated: Utc::now() }
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
use chrono::NaiveDateTime;
|
||||
use chrono::{Utc, DateTime};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use rust_decimal::Decimal;
|
||||
use crate::domain::league::LeagueVisibility;
|
||||
|
@ -15,7 +15,7 @@ pub struct LeagueForCreationDto{
|
|||
pub place_id: u32,
|
||||
pub visibility: Option<LeagueVisibility>,
|
||||
#[serde(rename = "dateAndTime")]
|
||||
pub date_and_time: NaiveDateTime,
|
||||
pub date_and_time: DateTime<Utc>,
|
||||
#[serde(rename = "costToJoin")]
|
||||
pub cost_to_join: Decimal,
|
||||
pub currency: Option<String>,
|
||||
|
|
Loading…
Reference in New Issue