1use chrono::{DateTime, Local, TimeZone, SecondsFormat};
2
3pub fn generate_timestamp(offset_seconds: i64, format: &str) -> Result<String, String> {
4 let now = Local::now();
5 let target_time = now + chrono::Duration::seconds(offset_seconds);
6
7 match format.to_lowercase().as_str() {
8 "rfc3339" => Ok(target_time.to_rfc3339_opts(SecondsFormat::Secs, true)),
9 "default" => Ok(target_time.format("%Y-%m-%d %H:%M:%S").to_string()),
10 other => Err(format!("Unsupported format: {}", other)),
11 }
12}