In the following function, timestamp_subsec_millis should be timestamp_subsec_nanos and consequently .and_hms_milli needs to be and_hms_nano. Otherwise the trailing 6 digits are always going to be 0, regardless of the input.
pub extern "C" fn DATE_AND_TIME_TO_TIME_OF_DAY(input: i64) -> i64 {
let date_time = chrono::Utc.timestamp_nanos(input);
// --snip
let milli = date_time.timestamp_subsec_millis();
let new_date_time =
chrono::NaiveDate::from_ymd(1970, 1, 1).and_hms_milli(hour, min, sec, milli);
new_date_time.timestamp_nanos()
}
In the following function, timestamp_subsec_millis should be timestamp_subsec_nanos and consequently .and_hms_milli needs to be and_hms_nano. Otherwise the trailing 6 digits are always going to be 0, regardless of the input.