use local timestamp for log
This commit is contained in:
		@@ -62,7 +62,7 @@ CREATE TABLE IF NOT EXISTS "user_trip" (
 | 
				
			|||||||
CREATE TABLE IF NOT EXISTS "log" (
 | 
					CREATE TABLE IF NOT EXISTS "log" (
 | 
				
			||||||
	"id" integer NOT NULL PRIMARY KEY AUTOINCREMENT,
 | 
						"id" integer NOT NULL PRIMARY KEY AUTOINCREMENT,
 | 
				
			||||||
	"msg" text NOT NULL,
 | 
						"msg" text NOT NULL,
 | 
				
			||||||
	"created_at" text NOT NULL DEFAULT CURRENT_TIMESTAMP
 | 
						"created_at" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
 | 
				
			||||||
);
 | 
					);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
CREATE TABLE IF NOT EXISTS "location" (
 | 
					CREATE TABLE IF NOT EXISTS "location" (
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,10 +1,11 @@
 | 
				
			|||||||
 | 
					use chrono::{DateTime, Local, NaiveDateTime, Utc};
 | 
				
			||||||
use serde::{Deserialize, Serialize};
 | 
					use serde::{Deserialize, Serialize};
 | 
				
			||||||
use sqlx::{FromRow, SqlitePool};
 | 
					use sqlx::{FromRow, SqlitePool};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#[derive(FromRow, Debug, Serialize, Deserialize)]
 | 
					#[derive(FromRow, Debug, Serialize, Deserialize)]
 | 
				
			||||||
pub struct Log {
 | 
					pub struct Log {
 | 
				
			||||||
    pub msg: String,
 | 
					    pub msg: String,
 | 
				
			||||||
    pub created_at: String,
 | 
					    pub created_at: NaiveDateTime,
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
impl Log {
 | 
					impl Log {
 | 
				
			||||||
@@ -40,8 +41,10 @@ LIMIT 1000
 | 
				
			|||||||
<description>An RSS feed with activities from app.rudernlinz.at</description>"#,
 | 
					<description>An RSS feed with activities from app.rudernlinz.at</description>"#,
 | 
				
			||||||
        );
 | 
					        );
 | 
				
			||||||
        for log in Self::last(db).await {
 | 
					        for log in Self::last(db).await {
 | 
				
			||||||
 | 
					            let utc_time: DateTime<Utc> = DateTime::from_utc(log.created_at, Utc);
 | 
				
			||||||
 | 
					            let local_time = utc_time.with_timezone(&Local);
 | 
				
			||||||
            ret.push_str("<item><title>");
 | 
					            ret.push_str("<item><title>");
 | 
				
			||||||
            ret.push_str(&format!("({}) {}", log.created_at, log.msg));
 | 
					            ret.push_str(&format!("({}) {}", local_time, log.msg));
 | 
				
			||||||
            ret.push_str("</title></item>");
 | 
					            ret.push_str("</title></item>");
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        ret.push_str("</channel>");
 | 
					        ret.push_str("</channel>");
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user