ld-lucivy 0.26.1

BM25 search engine with cross-token fuzzy matching, substring search, regex, and highlights
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use time::format_description::well_known::Rfc3339;
use time::OffsetDateTime;

use crate::LucivyError;

pub(crate) fn format_date(val: i64) -> crate::Result<String> {
    let datetime = OffsetDateTime::from_unix_timestamp_nanos(val as i128).map_err(|err| {
        LucivyError::InvalidArgument(format!(
            "Could not convert {val:?} to OffsetDateTime, err {err:?}"
        ))
    })?;
    let key_as_string = datetime
        .format(&Rfc3339)
        .map_err(|_err| LucivyError::InvalidArgument("Could not serialize date".to_string()))?;
    Ok(key_as_string)
}