From c9854a4f5c195ab60d4222f44a6df76ea6aff2c7 Mon Sep 17 00:00:00 2001 From: pheobeayo Date: Thu, 29 Aug 2024 11:49:47 +0100 Subject: [PATCH 1/3] cleanup-update --- src/config.rs | 1 - src/endpoints/achievements/verify_seniority.rs | 11 ++++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/config.rs b/src/config.rs index 814e5ea8..a6c927ea 100644 --- a/src/config.rs +++ b/src/config.rs @@ -1,6 +1,5 @@ use serde::{self, Deserialize, Deserializer}; use starknet::core::types::FieldElement; -use std::collections::HashMap; use std::env; use std::fs; diff --git a/src/endpoints/achievements/verify_seniority.rs b/src/endpoints/achievements/verify_seniority.rs index 036c8272..4d6956f9 100644 --- a/src/endpoints/achievements/verify_seniority.rs +++ b/src/endpoints/achievements/verify_seniority.rs @@ -12,7 +12,8 @@ use axum::{ Json, }; use axum_auto_routes::route; -use chrono::{NaiveDateTime, Utc}; +use chrono::{TimeZone, Utc}; +use chrono::Datelike; use serde_json::json; use starknet::core::types::FieldElement; @@ -33,10 +34,10 @@ pub async fn handler( match execute_has_deployed_time(state.clone(), &query.addr).await { Ok(timestamp) => { - let dt = NaiveDateTime::from_timestamp_opt(timestamp as i64, 0).unwrap(); - let current_time = Utc::now().naive_utc(); - let duration = current_time - dt; - let days_passed = duration.num_days(); + let timestamp_u64 = 1657113606; + let date_time = Utc.timestamp_opt(timestamp_u64 as i64, 0).unwrap(); + let duration = date_time ; + let days_passed = duration.num_days_from_ce(); if (achievement_id == 14 && days_passed >= 90) || (achievement_id == 15 && days_passed >= 180) || (achievement_id == 16 && days_passed >= 365) From 3df5ca2caaa79387a74c55a496e6501abdcd2897 Mon Sep 17 00:00:00 2001 From: pheobeayo Date: Fri, 30 Aug 2024 00:17:03 +0100 Subject: [PATCH 2/3] update --- src/endpoints/achievements/verify_seniority.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/endpoints/achievements/verify_seniority.rs b/src/endpoints/achievements/verify_seniority.rs index 4d6956f9..e5b8ed81 100644 --- a/src/endpoints/achievements/verify_seniority.rs +++ b/src/endpoints/achievements/verify_seniority.rs @@ -12,7 +12,7 @@ use axum::{ Json, }; use axum_auto_routes::route; -use chrono::{TimeZone, Utc}; +use chrono::{TimeZone, Utc, DateTime}; use chrono::Datelike; use serde_json::json; use starknet::core::types::FieldElement; @@ -34,8 +34,8 @@ pub async fn handler( match execute_has_deployed_time(state.clone(), &query.addr).await { Ok(timestamp) => { - let timestamp_u64 = 1657113606; - let date_time = Utc.timestamp_opt(timestamp_u64 as i64, 0).unwrap(); + + let date_time = DateTime::from_timestamp(timestamp as i64, 0).unwrap(); let duration = date_time ; let days_passed = duration.num_days_from_ce(); if (achievement_id == 14 && days_passed >= 90) From adc37937054f67eee5bc888d067bbeef4563975e Mon Sep 17 00:00:00 2001 From: pheobeayo Date: Fri, 30 Aug 2024 11:22:28 +0100 Subject: [PATCH 3/3] updated --- src/endpoints/achievements/verify_seniority.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/endpoints/achievements/verify_seniority.rs b/src/endpoints/achievements/verify_seniority.rs index e5b8ed81..0ff48a47 100644 --- a/src/endpoints/achievements/verify_seniority.rs +++ b/src/endpoints/achievements/verify_seniority.rs @@ -12,8 +12,7 @@ use axum::{ Json, }; use axum_auto_routes::route; -use chrono::{TimeZone, Utc, DateTime}; -use chrono::Datelike; +use chrono::{Utc, DateTime}; use serde_json::json; use starknet::core::types::FieldElement; @@ -36,8 +35,9 @@ pub async fn handler( Ok(timestamp) => { let date_time = DateTime::from_timestamp(timestamp as i64, 0).unwrap(); - let duration = date_time ; - let days_passed = duration.num_days_from_ce(); + let current_time = Utc::now(); + let duration = current_time - date_time; + let days_passed = duration.num_days(); if (achievement_id == 14 && days_passed >= 90) || (achievement_id == 15 && days_passed >= 180) || (achievement_id == 16 && days_passed >= 365)