Skip to content

Commit 98c105b

Browse files
committed
fixup! editoast: change stdcm environment date type
1 parent a4621b4 commit 98c105b

File tree

1 file changed

+12
-63
lines changed

1 file changed

+12
-63
lines changed

editoast/src/models/stdcm_search_environment.rs

+12-63
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ impl StdcmSearchEnvironmentChangeset {
6666

6767
#[cfg(test)]
6868
pub mod tests {
69-
use chrono::NaiveDate;
69+
use chrono::TimeZone;
70+
use chrono::Utc;
7071
use pretty_assertions::assert_eq;
7172
use rstest::rstest;
7273

@@ -128,31 +129,11 @@ pub mod tests {
128129
.work_schedule_group_id(Some(work_schedule_group.id))
129130
.temporary_speed_limit_group_id(Some(temporary_speed_limit_group.id))
130131
.timetable_id(timetable.id)
131-
.search_window_begin(
132-
NaiveDate::from_ymd_opt(2024, 1, 1)
133-
.unwrap()
134-
.and_hms_opt(0, 0, 0)
135-
.unwrap()
136-
.and_utc(),
137-
)
138-
.search_window_end(
139-
NaiveDate::from_ymd_opt(2024, 1, 15)
140-
.unwrap()
141-
.and_hms_opt(0, 0, 0)
142-
.unwrap()
143-
.and_utc(),
144-
);
132+
.search_window_begin(Utc.with_ymd_and_hms(2024, 1, 1, 0, 0, 0).unwrap())
133+
.search_window_end(Utc.with_ymd_and_hms(2024, 1, 15, 0, 0, 0).unwrap());
145134

146-
let begin = NaiveDate::from_ymd_opt(2024, 1, 16)
147-
.unwrap()
148-
.and_hms_opt(0, 0, 0)
149-
.unwrap()
150-
.and_utc();
151-
let end = NaiveDate::from_ymd_opt(2024, 1, 31)
152-
.unwrap()
153-
.and_hms_opt(0, 0, 0)
154-
.unwrap()
155-
.and_utc();
135+
let begin = Utc.with_ymd_and_hms(2024, 1, 16, 0, 0, 0).unwrap();
136+
let end = Utc.with_ymd_and_hms(2024, 1, 13, 0, 0, 0).unwrap();
156137

157138
let changeset_2 = changeset_1
158139
.clone()
@@ -211,48 +192,16 @@ pub mod tests {
211192
.work_schedule_group_id(Some(work_schedule_group.id))
212193
.temporary_speed_limit_group_id(Some(temporary_speed_limit_group.id))
213194
.timetable_id(timetable.id)
214-
.search_window_begin(
215-
NaiveDate::from_ymd_opt(2024, 1, 1)
216-
.unwrap()
217-
.and_hms_opt(0, 0, 0)
218-
.unwrap()
219-
.and_utc(),
220-
)
221-
.search_window_end(
222-
NaiveDate::from_ymd_opt(2024, 1, 15)
223-
.unwrap()
224-
.and_hms_opt(0, 0, 0)
225-
.unwrap()
226-
.and_utc(),
227-
);
195+
.search_window_begin(Utc.with_ymd_and_hms(2024, 1, 1, 0, 0, 0).unwrap())
196+
.search_window_end(Utc.with_ymd_and_hms(2024, 1, 15, 0, 0, 0).unwrap());
228197

229198
let too_young = too_old
230199
.clone()
231-
.search_window_begin(
232-
NaiveDate::from_ymd_opt(2024, 1, 16)
233-
.unwrap()
234-
.and_hms_opt(0, 0, 0)
235-
.unwrap()
236-
.and_utc(),
237-
)
238-
.search_window_end(
239-
NaiveDate::from_ymd_opt(2024, 1, 31)
240-
.unwrap()
241-
.and_hms_opt(0, 0, 0)
242-
.unwrap()
243-
.and_utc(),
244-
);
200+
.search_window_begin(Utc.with_ymd_and_hms(2024, 1, 16, 0, 0, 0).unwrap())
201+
.search_window_end(Utc.with_ymd_and_hms(2024, 1, 31, 0, 0, 0).unwrap());
245202

246-
let begin = NaiveDate::from_ymd_opt(2024, 1, 7)
247-
.unwrap()
248-
.and_hms_opt(0, 0, 0)
249-
.unwrap()
250-
.and_utc();
251-
let end = NaiveDate::from_ymd_opt(2024, 1, 31)
252-
.unwrap()
253-
.and_hms_opt(0, 0, 0)
254-
.unwrap()
255-
.and_utc();
203+
let begin = Utc.with_ymd_and_hms(2024, 1, 7, 0, 0, 0).unwrap();
204+
let end = Utc.with_ymd_and_hms(2024, 1, 31, 0, 0, 0).unwrap();
256205

257206
let the_best = too_old
258207
.clone()

0 commit comments

Comments
 (0)