Skip to content

Commit b0fa85a

Browse files
authored
Merge pull request #9 from he1senbrg/master
Fix: Change timezone to Asia/Kolkata
2 parents e5ce7a8 + e109493 commit b0fa85a

File tree

4 files changed

+58
-8
lines changed

4 files changed

+58
-8
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: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,5 @@ sqlx = { version = "0.7.1", features = ["chrono"] }
1616
tokio = "1.28.2"
1717
hmac = "0.12.1"
1818
sha2 = "0.10.8"
19-
hex = "0.4.3"
19+
hex = "0.4.3"
20+
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
@@ -6,7 +6,7 @@ use std::time::Duration;
66
use async_graphql_axum::GraphQL;
77
use axum::{routing::get, Router};
88
use chrono::{ Local, NaiveTime};
9-
9+
use chrono_tz::Asia::Kolkata;
1010
use db::member::Member;
1111
use sqlx::PgPool;
1212
use async_graphql::{ Schema, EmptySubscription};
@@ -63,7 +63,7 @@ async fn scheduled_task(pool: Arc<PgPool>) {
6363

6464
match members {
6565
Ok(members) => {
66-
let today = Local::now().naive_local();
66+
let today = Local::now().with_timezone(&Kolkata);
6767

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

0 commit comments

Comments
 (0)