mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 13:36:07 +02:00
Fix chrono
deprecation warnings (#12091)
# Description Bumps `chrono` to 0.4.35 and fixes any deprecation warnings.
This commit is contained in:
@ -280,7 +280,9 @@ pub fn run_seq_dates(
|
||||
}
|
||||
|
||||
if days_to_output != 0 {
|
||||
end_date = match start_date.checked_add_signed(Duration::days(days_to_output)) {
|
||||
end_date = match Duration::try_days(days_to_output)
|
||||
.and_then(|days| start_date.checked_add_signed(days))
|
||||
{
|
||||
Some(date) => date,
|
||||
None => {
|
||||
return Err(ShellError::GenericError {
|
||||
@ -303,6 +305,16 @@ pub fn run_seq_dates(
|
||||
let is_out_of_range =
|
||||
|next| (step_size > 0 && next > end_date) || (step_size < 0 && next < end_date);
|
||||
|
||||
let Some(step_size) = Duration::try_days(step_size) else {
|
||||
return Err(ShellError::GenericError {
|
||||
error: "increment magnitude is too large".into(),
|
||||
msg: "increment magnitude is too large".into(),
|
||||
span: Some(call_span),
|
||||
help: None,
|
||||
inner: vec![],
|
||||
});
|
||||
};
|
||||
|
||||
let mut next = start_date;
|
||||
if is_out_of_range(next) {
|
||||
return Err(ShellError::GenericError {
|
||||
@ -330,7 +342,7 @@ pub fn run_seq_dates(
|
||||
}
|
||||
}
|
||||
ret.push(Value::string(date_string, call_span));
|
||||
next += Duration::days(step_size);
|
||||
next += step_size;
|
||||
|
||||
if is_out_of_range(next) {
|
||||
break;
|
||||
|
@ -1,6 +1,6 @@
|
||||
use std::{io::Write, path::PathBuf};
|
||||
|
||||
use chrono::{DateTime, FixedOffset, NaiveDateTime, Offset};
|
||||
use chrono::{DateTime, FixedOffset};
|
||||
use nu_protocol::{ast::PathMember, record, Span, Value};
|
||||
use nu_test_support::{
|
||||
fs::{line_ending, Stub},
|
||||
@ -280,9 +280,10 @@ impl Distribution<TestRow> for Standard {
|
||||
where
|
||||
R: rand::Rng + ?Sized,
|
||||
{
|
||||
let naive_dt =
|
||||
NaiveDateTime::from_timestamp_millis(rng.gen_range(0..2324252554000)).unwrap();
|
||||
let dt = DateTime::from_naive_utc_and_offset(naive_dt, chrono::Utc.fix());
|
||||
let dt = DateTime::from_timestamp_millis(rng.gen_range(0..2324252554000))
|
||||
.unwrap()
|
||||
.fixed_offset();
|
||||
|
||||
let rand_string = Alphanumeric.sample_string(rng, 10);
|
||||
|
||||
// limit the size of the numbers to work around
|
||||
|
Reference in New Issue
Block a user