I'm a python guy trying to do a few things in Rust.
I have this bit of code:
for row in rows {
let (laterality, scan_date_days, modality, file_path) = row.unwrap();
let scan_date = NaiveDate::from_num_days_from_ce(scan_date_days);
let file_name = Path::new(&file_path)
.file_name()
.unwrap()
.to_string_lossy()
.to_string();
let output_file_name = format!("{}_{}", modality, file_name);
let formatted_date = scan_date.format("%d-%b-%Y").to_string().to_uppercase();
let patient_folder = Path::new(output_directory)
.join(format!("{}_{}_{}", patient_id, laterality, formatted_date));
First, I'm failing to move from from_num_days_from_ce to from_num_days_from_ce_opt.
In python, scan_date_days is datetime object (e.g. datetime.date(2017, 12, 18)). And I get the right formatted_date: 18-DEC-2017.
However, the rust code above is giving 16-DEC-0048.
I'm a python guy trying to do a few things in Rust.
I have this bit of code:
First, I'm failing to move from
from_num_days_from_ce
tofrom_num_days_from_ce_opt
.In python,
scan_date_days
isdatetime
object (e.g.datetime.date(2017, 12, 18)
). And I get the rightformatted_date
:18-DEC-2017
. However, the rust code above is giving16-DEC-0048
.What am I missing, please?