make default duration 3 hrs (to have a larger block in the cal)

This commit is contained in:
Philipp Hofer 2025-04-15 23:12:30 +02:00
parent f42bf5ea3a
commit eb9dd3f864
2 changed files with 32 additions and 4 deletions

View File

@ -1,8 +1,8 @@
use std::io::Write;
use chrono::NaiveDate;
use chrono::{Duration, NaiveDate, NaiveTime};
use ics::{
properties::{DtStart, Summary},
properties::{DtEnd, DtStart, Summary},
ICalendar,
};
use serde::Serialize;
@ -452,6 +452,20 @@ WHERE trip_details.id=?
self.day.replace('-', ""),
self.planned_starting_time.replace(':', "")
)));
let original_time = NaiveTime::parse_from_str(&self.planned_starting_time, "%H:%M")
.expect("Failed to parse time");
let later_time = original_time + Duration::hours(3);
if later_time > original_time {
// Check if no day-overflow
let time_three_hours_later = later_time.format("%H%M").to_string();
vevent.push(DtEnd::new(format!(
"{}T{}00",
self.day.replace('-', ""),
time_three_hours_later
)));
}
let tripdetails = self.trip_details(db).await;
let mut name = String::new();
if self.is_cancelled() {

View File

@ -1,5 +1,5 @@
use chrono::{Local, NaiveDate};
use ics::properties::{DtStart, Summary};
use chrono::{Duration, Local, NaiveDate, NaiveTime};
use ics::properties::{DtEnd, DtStart, Summary};
use serde::Serialize;
use sqlx::SqlitePool;
@ -145,6 +145,20 @@ WHERE trip_details.id=?
self.day.replace('-', ""),
self.planned_starting_time.replace(':', "")
)));
let original_time = NaiveTime::parse_from_str(&self.planned_starting_time, "%H:%M")
.expect("Failed to parse time");
let later_time = original_time + Duration::hours(3);
if later_time > original_time {
// Check if no day-overflow
let time_three_hours_later = later_time.format("%H%M").to_string();
vevent.push(DtEnd::new(format!(
"{}T{}00",
self.day.replace('-', ""),
time_three_hours_later
)));
}
let mut name = String::new();
if self.is_cancelled() {
name.push_str("ABGESAGT");