fix date parsing

This commit is contained in:
Yannik 2023-04-26 20:40:50 +02:00
parent 369c4ccdbe
commit 6fb7b1c142

View file

@ -286,13 +286,16 @@ fn parse_line(line: &'_ str) -> Result<ParsedLine<'_>, Error> {
.parse()
.map_err(|e| format!("could not parse priority {}: {}", prio, e))?;
let (date, line) = line.split_at(16);
let (date, line) = line.split_at(15);
let rcvtime = chrono::Local::now();
// we need to prepend the current year and add timezone, as that is not stated in the logfile
let logtime = parse_log_date(rcvtime.date_naive().year(), date)
.map_err(|e| format!("could not parse logtime {}{} {}", date, line, e))?;
let logtime = TimeZone::from_local_datetime(&Local, &logtime).unwrap();
// skip seperator
let line = &line[1..];
// this slightly differs from the rfc: - is considered non-terminating
let (service, entry) = line
.split_once(|c: char| !((c == '-') || c.is_alphanumeric()))