Skip to content

Commit 9dff096

Browse files
committed
add: tower
2 parents d8f5b9c + b0fa85a commit 9dff096

File tree

4 files changed

+57
-7
lines changed

4 files changed

+57
-7
lines changed

Cargo.lock

Lines changed: 51 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,4 @@ sha2 = "0.10.8"
1919
hex = "0.4.3"
2020
tower-http = { version = "0.6.1", features = ["cors"] }
2121
tower = "0.5.1"
22+
chrono-tz = "0.10.0"

src/graphql/mutations.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
use async_graphql::{Context, Object};
22
use ::chrono::Local;
33
use chrono::{NaiveDate, NaiveTime};
4+
use chrono_tz::Asia::Kolkata;
45
use sqlx::PgPool;
5-
use sqlx::types::chrono;
6+
use sqlx::types::chrono;
67
use std::sync::Arc;
78
use hmac::{Hmac,Mac};
89
use sha2::Sha256;
@@ -113,10 +114,7 @@ impl MutationRoot {
113114
return Err(sqlx::Error::Protocol("HMAC verification failed".into()));
114115
}
115116

116-
117-
118-
119-
let current_time = Local::now().time();
117+
let current_time = Local::now().with_timezone(&Kolkata).time();
120118

121119
let attendance = sqlx::query_as::<_, Attendance>(
122120
"

src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use async_graphql_axum::GraphQL;
77
use axum::{routing::get, Router};
88
use tower_http::cors::{Any, CorsLayer};
99
use chrono::{ Local, NaiveTime};
10-
10+
use chrono_tz::Asia::Kolkata;
1111
use db::member::Member;
1212
use sqlx::PgPool;
1313
use async_graphql::{ Schema, EmptySubscription};
@@ -70,7 +70,7 @@ async fn scheduled_task(pool: Arc<PgPool>) {
7070

7171
match members {
7272
Ok(members) => {
73-
let today = Local::now().naive_local();
73+
let today = Local::now().with_timezone(&Kolkata);
7474

7575
for member in members {
7676
let timein = NaiveTime::from_hms_opt(0, 0, 0);

0 commit comments

Comments
 (0)