Skip to content

Commit 22b4d32

Browse files
committed
Avoid use of deprecated API
1 parent 77317d5 commit 22b4d32

File tree

21 files changed

+574
-393
lines changed

21 files changed

+574
-393
lines changed

benches/chrono.rs

+16-2
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,27 @@ fn bench_datetime_from_str(c: &mut Criterion) {
3636

3737
fn bench_datetime_to_rfc2822(c: &mut Criterion) {
3838
let pst = FixedOffset::east_opt(8 * 60 * 60).unwrap();
39-
let dt = pst.ymd_opt(2018, 1, 11).unwrap().and_hms_nano_opt(10, 5, 13, 84_660_000).unwrap();
39+
let dt = pst
40+
.from_local_datetime(
41+
&NaiveDate::from_ymd_opt(2018, 1, 11)
42+
.unwrap()
43+
.and_hms_nano_opt(10, 5, 13, 84_660_000)
44+
.unwrap(),
45+
)
46+
.unwrap();
4047
c.bench_function("bench_datetime_to_rfc2822", |b| b.iter(|| black_box(dt).to_rfc2822()));
4148
}
4249

4350
fn bench_datetime_to_rfc3339(c: &mut Criterion) {
4451
let pst = FixedOffset::east_opt(8 * 60 * 60).unwrap();
45-
let dt = pst.ymd_opt(2018, 1, 11).and_hms_nano_opt(10, 5, 13, 84_660_000).unwrap();
52+
let dt = pst
53+
.from_local_datetime(
54+
&NaiveDate::from_ymd_opt(2018, 1, 11)
55+
.unwrap()
56+
.and_hms_nano_opt(10, 5, 13, 84_660_000)
57+
.unwrap(),
58+
)
59+
.unwrap();
4660
c.bench_function("bench_datetime_to_rfc3339", |b| b.iter(|| black_box(dt).to_rfc3339()));
4761
}
4862

ci/core-test/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
use chrono::{TimeZone, Utc};
44

55
pub fn create_time() {
6-
let _ = Utc.ymd_opt(2019, 1, 1).unwrap().and_hms_opt(0, 0, 0).unwrap();
6+
let _ = Utc.with_ymd_and_hms(2019, 1, 1, 0, 0, 0).unwrap();
77
}

src/date.rs

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// See README.md and LICENSE.txt for details.
33

44
//! ISO 8601 calendar date with time zone.
5+
#![allow(deprecated)]
56

67
#[cfg(any(feature = "alloc", feature = "std", test))]
78
use core::borrow::Borrow;

src/datetime/mod.rs

+49-98
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ use crate::naive::{Days, IsoWeek, NaiveDate, NaiveDateTime, NaiveTime};
3030
use crate::offset::Local;
3131
use crate::offset::{FixedOffset, Offset, TimeZone, Utc};
3232
use crate::oldtime::Duration as OldDuration;
33+
#[allow(deprecated)]
3334
use crate::Date;
3435
use crate::Months;
3536
use crate::{Datelike, Timelike, Weekday};
@@ -167,8 +168,8 @@ impl<Tz: TimeZone> DateTime<Tz> {
167168
/// ```
168169
/// use chrono::prelude::*;
169170
///
170-
/// let date: DateTime<Utc> = Utc.ymd_opt(2020, 1, 1).unwrap().and_hms_opt(0, 0, 0).unwrap();
171-
/// let other: DateTime<FixedOffset> = FixedOffset::east_opt(23).unwrap().ymd_opt(2020, 1, 1).unwrap().and_hms_opt(0, 0, 0).unwrap();
171+
/// let date: DateTime<Utc> = Utc.with_ymd_and_hms(2020, 1, 1, 0, 0, 0).unwrap();
172+
/// let other: DateTime<FixedOffset> = FixedOffset::east_opt(23).unwrap().with_ymd_and_hms(2020, 1, 1, 0, 0, 0).unwrap();
172173
/// assert_eq!(date.date_naive(), other.date_naive());
173174
/// ```
174175
#[inline]
@@ -201,13 +202,12 @@ impl<Tz: TimeZone> DateTime<Tz> {
201202
/// # Example
202203
///
203204
/// ```
204-
/// use chrono::Utc;
205-
/// use chrono::TimeZone;
205+
/// use chrono::{Utc, TimeZone, NaiveDate};
206206
///
207-
/// let dt = Utc.ymd_opt(1970, 1, 1).unwrap().and_hms_milli_opt(0, 0, 1, 444).unwrap();
207+
/// let dt = NaiveDate::from_ymd_opt(1970, 1, 1).unwrap().and_hms_milli_opt(0, 0, 1, 444).unwrap().and_local_timezone(Utc).unwrap();
208208
/// assert_eq!(dt.timestamp_millis(), 1_444);
209209
///
210-
/// let dt = Utc.ymd_opt(2001, 9, 9).unwrap().and_hms_milli_opt(1, 46, 40, 555).unwrap();
210+
/// let dt = NaiveDate::from_ymd_opt(2001, 9, 9).unwrap().and_hms_milli_opt(1, 46, 40, 555).unwrap().and_local_timezone(Utc).unwrap();
211211
/// assert_eq!(dt.timestamp_millis(), 1_000_000_000_555);
212212
/// ```
213213
#[inline]
@@ -225,13 +225,12 @@ impl<Tz: TimeZone> DateTime<Tz> {
225225
/// # Example
226226
///
227227
/// ```
228-
/// use chrono::Utc;
229-
/// use chrono::TimeZone;
228+
/// use chrono::{Utc, TimeZone, NaiveDate};
230229
///
231-
/// let dt = Utc.ymd_opt(1970, 1, 1).unwrap().and_hms_micro_opt(0, 0, 1, 444).unwrap();
230+
/// let dt = NaiveDate::from_ymd_opt(1970, 1, 1).unwrap().and_hms_micro_opt(0, 0, 1, 444).unwrap().and_local_timezone(Utc).unwrap();
232231
/// assert_eq!(dt.timestamp_micros(), 1_000_444);
233232
///
234-
/// let dt = Utc.ymd_opt(2001, 9, 9).unwrap().and_hms_micro_opt(1, 46, 40, 555).unwrap();
233+
/// let dt = NaiveDate::from_ymd_opt(2001, 9, 9).unwrap().and_hms_micro_opt(1, 46, 40, 555).unwrap().and_local_timezone(Utc).unwrap();
235234
/// assert_eq!(dt.timestamp_micros(), 1_000_000_000_000_555);
236235
/// ```
237236
#[inline]
@@ -249,13 +248,12 @@ impl<Tz: TimeZone> DateTime<Tz> {
249248
/// # Example
250249
///
251250
/// ```
252-
/// use chrono::Utc;
253-
/// use chrono::TimeZone;
251+
/// use chrono::{Utc, TimeZone, NaiveDate};
254252
///
255-
/// let dt = Utc.ymd_opt(1970, 1, 1).unwrap().and_hms_nano_opt(0, 0, 1, 444).unwrap();
253+
/// let dt = NaiveDate::from_ymd_opt(1970, 1, 1).unwrap().and_hms_nano_opt(0, 0, 1, 444).unwrap().and_local_timezone(Utc).unwrap();
256254
/// assert_eq!(dt.timestamp_nanos(), 1_000_000_444);
257255
///
258-
/// let dt = Utc.ymd_opt(2001, 9, 9).unwrap().and_hms_nano_opt(1, 46, 40, 555).unwrap();
256+
/// let dt = NaiveDate::from_ymd_opt(2001, 9, 9).unwrap().and_hms_nano_opt(1, 46, 40, 555).unwrap().and_local_timezone(Utc).unwrap();
259257
/// assert_eq!(dt.timestamp_nanos(), 1_000_000_000_000_000_555);
260258
/// ```
261259
#[inline]
@@ -529,10 +527,10 @@ impl DateTime<FixedOffset> {
529527
/// representation of times in HTTP and email headers.
530528
///
531529
/// ```
532-
/// # use chrono::{DateTime, FixedOffset, TimeZone};
530+
/// # use chrono::{DateTime, FixedOffset, TimeZone, NaiveDate};
533531
/// assert_eq!(
534532
/// DateTime::parse_from_rfc2822("Wed, 18 Feb 2015 23:16:09 GMT").unwrap(),
535-
/// FixedOffset::east_opt(0).unwrap().ymd_opt(2015, 2, 18).unwrap().and_hms_opt(23, 16, 9).unwrap()
533+
/// FixedOffset::east_opt(0).unwrap().with_ymd_and_hms(2015, 2, 18, 23, 16, 9).unwrap()
536534
/// );
537535
/// ```
538536
pub fn parse_from_rfc2822(s: &str) -> ParseResult<DateTime<FixedOffset>> {
@@ -570,11 +568,11 @@ impl DateTime<FixedOffset> {
570568
/// # Example
571569
///
572570
/// ```rust
573-
/// use chrono::{DateTime, FixedOffset, TimeZone};
571+
/// use chrono::{DateTime, FixedOffset, TimeZone, NaiveDate};
574572
///
575573
/// let dt = DateTime::parse_from_str(
576574
/// "1983 Apr 13 12:09:14.274 +0000", "%Y %b %d %H:%M:%S%.3f %z");
577-
/// assert_eq!(dt, Ok(FixedOffset::east_opt(0).unwrap().ymd_opt(1983, 4, 13).unwrap().and_hms_milli_opt(12, 9, 14, 274).unwrap()));
575+
/// assert_eq!(dt, Ok(FixedOffset::east_opt(0).unwrap().from_local_datetime(&NaiveDate::from_ymd_opt(1983, 4, 13).unwrap().and_hms_milli_opt(12, 9, 14, 274).unwrap()).unwrap()));
578576
/// ```
579577
pub fn parse_from_str(s: &str, fmt: &str) -> ParseResult<DateTime<FixedOffset>> {
580578
let mut parsed = Parsed::new();
@@ -617,8 +615,8 @@ where
617615
/// # Examples
618616
///
619617
/// ```rust
620-
/// # use chrono::{DateTime, FixedOffset, SecondsFormat, TimeZone, Utc};
621-
/// let dt = Utc.ymd_opt(2018, 1, 26).unwrap().and_hms_micro_opt(18, 30, 9, 453_829).unwrap();
618+
/// # use chrono::{DateTime, FixedOffset, SecondsFormat, TimeZone, Utc, NaiveDate};
619+
/// let dt = NaiveDate::from_ymd_opt(2018, 1, 26).unwrap().and_hms_micro_opt(18, 30, 9, 453_829).unwrap().and_local_timezone(Utc).unwrap();
622620
/// assert_eq!(dt.to_rfc3339_opts(SecondsFormat::Millis, false),
623621
/// "2018-01-26T18:30:09.453+00:00");
624622
/// assert_eq!(dt.to_rfc3339_opts(SecondsFormat::Millis, true),
@@ -627,7 +625,7 @@ where
627625
/// "2018-01-26T18:30:09Z");
628626
///
629627
/// let pst = FixedOffset::east_opt(8 * 60 * 60).unwrap();
630-
/// let dt = pst.ymd_opt(2018, 1, 26).unwrap().and_hms_micro_opt(10, 30, 9, 453_829).unwrap();
628+
/// let dt = pst.from_local_datetime(&NaiveDate::from_ymd_opt(2018, 1, 26).unwrap().and_hms_micro_opt(10, 30, 9, 453_829).unwrap()).unwrap();
631629
/// assert_eq!(dt.to_rfc3339_opts(SecondsFormat::Secs, true),
632630
/// "2018-01-26T10:30:09+08:00");
633631
/// ```
@@ -696,7 +694,7 @@ where
696694
/// ```rust
697695
/// use chrono::prelude::*;
698696
///
699-
/// let date_time: DateTime<Utc> = Utc.ymd_opt(2017, 04, 02).unwrap().and_hms_opt(12, 50, 32).unwrap();
697+
/// let date_time: DateTime<Utc> = Utc.with_ymd_and_hms(2017, 04, 02, 12, 50, 32).unwrap();
700698
/// let formatted = format!("{}", date_time.format("%d/%m/%Y %H:%M"));
701699
/// assert_eq!(formatted, "02/04/2017 12:50");
702700
/// ```
@@ -880,8 +878,8 @@ impl<Tz: TimeZone, Tz2: TimeZone> PartialOrd<DateTime<Tz2>> for DateTime<Tz> {
880878
/// ```
881879
/// use chrono::prelude::*;
882880
///
883-
/// let earlier = Utc.ymd_opt(2015, 5, 15).unwrap().and_hms_opt(2, 0, 0).unwrap().with_timezone(&FixedOffset::west_opt(1 * 3600).unwrap());
884-
/// let later = Utc.ymd_opt(2015, 5, 15).unwrap().and_hms_opt(3, 0, 0).unwrap().with_timezone(&FixedOffset::west_opt(5 * 3600).unwrap());
881+
/// let earlier = Utc.with_ymd_and_hms(2015, 5, 15, 2, 0, 0).unwrap().with_timezone(&FixedOffset::west_opt(1 * 3600).unwrap());
882+
/// let later = Utc.with_ymd_and_hms(2015, 5, 15, 3, 0, 0).unwrap().with_timezone(&FixedOffset::west_opt(5 * 3600).unwrap());
885883
///
886884
/// assert_eq!(earlier.to_string(), "2015-05-15 01:00:00 -01:00");
887885
/// assert_eq!(later.to_string(), "2015-05-14 22:00:00 -05:00");
@@ -1166,47 +1164,27 @@ where
11661164

11671165
#[test]
11681166
fn test_add_sub_months() {
1169-
let utc_dt = Utc.ymd_opt(2018, 9, 5).unwrap().and_hms_opt(23, 58, 0).unwrap();
1170-
assert_eq!(
1171-
utc_dt + Months::new(15),
1172-
Utc.ymd_opt(2019, 12, 5).unwrap().and_hms_opt(23, 58, 0).unwrap()
1173-
);
1167+
let utc_dt = Utc.with_ymd_and_hms(2018, 9, 5, 23, 58, 0).unwrap();
1168+
assert_eq!(utc_dt + Months::new(15), Utc.with_ymd_and_hms(2019, 12, 5, 23, 58, 0).unwrap());
11741169

1175-
let utc_dt = Utc.ymd_opt(2020, 1, 31).unwrap().and_hms_opt(23, 58, 0).unwrap();
1176-
assert_eq!(
1177-
utc_dt + Months::new(1),
1178-
Utc.ymd_opt(2020, 2, 29).unwrap().and_hms_opt(23, 58, 0).unwrap()
1179-
);
1180-
assert_eq!(
1181-
utc_dt + Months::new(2),
1182-
Utc.ymd_opt(2020, 3, 31).unwrap().and_hms_opt(23, 58, 0).unwrap()
1183-
);
1170+
let utc_dt = Utc.with_ymd_and_hms(2020, 1, 31, 23, 58, 0).unwrap();
1171+
assert_eq!(utc_dt + Months::new(1), Utc.with_ymd_and_hms(2020, 2, 29, 23, 58, 0).unwrap());
1172+
assert_eq!(utc_dt + Months::new(2), Utc.with_ymd_and_hms(2020, 3, 31, 23, 58, 0).unwrap());
11841173

1185-
let utc_dt = Utc.ymd_opt(2018, 9, 5).unwrap().and_hms_opt(23, 58, 0).unwrap();
1186-
assert_eq!(
1187-
utc_dt - Months::new(15),
1188-
Utc.ymd_opt(2017, 6, 5).unwrap().and_hms_opt(23, 58, 0).unwrap()
1189-
);
1174+
let utc_dt = Utc.with_ymd_and_hms(2018, 9, 5, 23, 58, 0).unwrap();
1175+
assert_eq!(utc_dt - Months::new(15), Utc.with_ymd_and_hms(2017, 6, 5, 23, 58, 0).unwrap());
11901176

1191-
let utc_dt = Utc.ymd_opt(2020, 3, 31).unwrap().and_hms_opt(23, 58, 0).unwrap();
1192-
assert_eq!(
1193-
utc_dt - Months::new(1),
1194-
Utc.ymd_opt(2020, 2, 29).unwrap().and_hms_opt(23, 58, 0).unwrap()
1195-
);
1196-
assert_eq!(
1197-
utc_dt - Months::new(2),
1198-
Utc.ymd_opt(2020, 1, 31).unwrap().and_hms_opt(23, 58, 0).unwrap()
1199-
);
1177+
let utc_dt = Utc.with_ymd_and_hms(2020, 3, 31, 23, 58, 0).unwrap();
1178+
assert_eq!(utc_dt - Months::new(1), Utc.with_ymd_and_hms(2020, 2, 29, 23, 58, 0).unwrap());
1179+
assert_eq!(utc_dt - Months::new(2), Utc.with_ymd_and_hms(2020, 1, 31, 23, 58, 0).unwrap());
12001180
}
12011181

12021182
#[test]
12031183
fn test_auto_conversion() {
1204-
let utc_dt = Utc.ymd_opt(2018, 9, 5).unwrap().and_hms_opt(23, 58, 0).unwrap();
1184+
let utc_dt = Utc.with_ymd_and_hms(2018, 9, 5, 23, 58, 0).unwrap();
12051185
let cdt_dt = FixedOffset::west_opt(5 * 60 * 60)
12061186
.unwrap()
1207-
.ymd_opt(2018, 9, 5)
1208-
.unwrap()
1209-
.and_hms_opt(18, 58, 0)
1187+
.with_ymd_and_hms(2018, 9, 5, 18, 58, 0)
12101188
.unwrap();
12111189
let utc_dt2: DateTime<Utc> = cdt_dt.into();
12121190
assert_eq!(utc_dt, utc_dt2);
@@ -1220,30 +1198,20 @@ where
12201198
E: ::core::fmt::Debug,
12211199
{
12221200
assert_eq!(
1223-
to_string_utc(&Utc.ymd_opt(2014, 7, 24).unwrap().and_hms_opt(12, 34, 6).unwrap()).ok(),
1201+
to_string_utc(&Utc.with_ymd_and_hms(2014, 7, 24, 12, 34, 6).unwrap()).ok(),
12241202
Some(r#""2014-07-24T12:34:06Z""#.into())
12251203
);
12261204

12271205
assert_eq!(
12281206
to_string_fixed(
1229-
&FixedOffset::east_opt(3660)
1230-
.unwrap()
1231-
.ymd_opt(2014, 7, 24)
1232-
.unwrap()
1233-
.and_hms_opt(12, 34, 6)
1234-
.unwrap()
1207+
&FixedOffset::east_opt(3660).unwrap().with_ymd_and_hms(2014, 7, 24, 12, 34, 6).unwrap()
12351208
)
12361209
.ok(),
12371210
Some(r#""2014-07-24T12:34:06+01:01""#.into())
12381211
);
12391212
assert_eq!(
12401213
to_string_fixed(
1241-
&FixedOffset::east_opt(3650)
1242-
.unwrap()
1243-
.ymd_opt(2014, 7, 24)
1244-
.unwrap()
1245-
.and_hms_opt(12, 34, 6)
1246-
.unwrap()
1214+
&FixedOffset::east_opt(3650).unwrap().with_ymd_and_hms(2014, 7, 24, 12, 34, 6).unwrap()
12471215
)
12481216
.ok(),
12491217
Some(r#""2014-07-24T12:34:06+01:00:50""#.into())
@@ -1268,32 +1236,25 @@ fn test_decodable_json<FUtc, FFixed, FLocal, E>(
12681236

12691237
assert_eq!(
12701238
norm(&utc_from_str(r#""2014-07-24T12:34:06Z""#).ok()),
1271-
norm(&Some(Utc.ymd_opt(2014, 7, 24).unwrap().and_hms_opt(12, 34, 6).unwrap()))
1239+
norm(&Some(Utc.with_ymd_and_hms(2014, 7, 24, 12, 34, 6).unwrap()))
12721240
);
12731241
assert_eq!(
12741242
norm(&utc_from_str(r#""2014-07-24T13:57:06+01:23""#).ok()),
1275-
norm(&Some(Utc.ymd_opt(2014, 7, 24).unwrap().and_hms_opt(12, 34, 6).unwrap()))
1243+
norm(&Some(Utc.with_ymd_and_hms(2014, 7, 24, 12, 34, 6).unwrap()))
12761244
);
12771245

12781246
assert_eq!(
12791247
norm(&fixed_from_str(r#""2014-07-24T12:34:06Z""#).ok()),
12801248
norm(&Some(
1281-
FixedOffset::east_opt(0)
1282-
.unwrap()
1283-
.ymd_opt(2014, 7, 24)
1284-
.unwrap()
1285-
.and_hms_opt(12, 34, 6)
1286-
.unwrap()
1249+
FixedOffset::east_opt(0).unwrap().with_ymd_and_hms(2014, 7, 24, 12, 34, 6).unwrap()
12871250
))
12881251
);
12891252
assert_eq!(
12901253
norm(&fixed_from_str(r#""2014-07-24T13:57:06+01:23""#).ok()),
12911254
norm(&Some(
12921255
FixedOffset::east_opt(60 * 60 + 23 * 60)
12931256
.unwrap()
1294-
.ymd_opt(2014, 7, 24)
1295-
.unwrap()
1296-
.and_hms_opt(13, 57, 6)
1257+
.with_ymd_and_hms(2014, 7, 24, 13, 57, 6)
12971258
.unwrap()
12981259
))
12991260
);
@@ -1302,11 +1263,11 @@ fn test_decodable_json<FUtc, FFixed, FLocal, E>(
13021263
// the conversion didn't change the instant itself
13031264
assert_eq!(
13041265
local_from_str(r#""2014-07-24T12:34:06Z""#).expect("local shouuld parse"),
1305-
Utc.ymd_opt(2014, 7, 24).unwrap().and_hms_opt(12, 34, 6).unwrap()
1266+
Utc.with_ymd_and_hms(2014, 7, 24, 12, 34, 6).unwrap()
13061267
);
13071268
assert_eq!(
13081269
local_from_str(r#""2014-07-24T13:57:06+01:23""#).expect("local should parse with offset"),
1309-
Utc.ymd_opt(2014, 7, 24).unwrap().and_hms_opt(12, 34, 6).unwrap()
1270+
Utc.with_ymd_and_hms(2014, 7, 24, 12, 34, 6).unwrap()
13101271
);
13111272

13121273
assert!(utc_from_str(r#""2014-07-32T12:34:06Z""#).is_err());
@@ -1330,42 +1291,32 @@ fn test_decodable_json_timestamps<FUtc, FFixed, FLocal, E>(
13301291

13311292
assert_eq!(
13321293
norm(&utc_from_str("0").ok().map(DateTime::from)),
1333-
norm(&Some(Utc.ymd_opt(1970, 1, 1).unwrap().and_hms_opt(0, 0, 0).unwrap()))
1294+
norm(&Some(Utc.with_ymd_and_hms(1970, 1, 1, 0, 0, 0).unwrap()))
13341295
);
13351296
assert_eq!(
13361297
norm(&utc_from_str("-1").ok().map(DateTime::from)),
1337-
norm(&Some(Utc.ymd_opt(1969, 12, 31).unwrap().and_hms_opt(23, 59, 59).unwrap()))
1298+
norm(&Some(Utc.with_ymd_and_hms(1969, 12, 31, 23, 59, 59).unwrap()))
13381299
);
13391300

13401301
assert_eq!(
13411302
norm(&fixed_from_str("0").ok().map(DateTime::from)),
13421303
norm(&Some(
1343-
FixedOffset::east_opt(0)
1344-
.unwrap()
1345-
.ymd_opt(1970, 1, 1)
1346-
.unwrap()
1347-
.and_hms_opt(0, 0, 0)
1348-
.unwrap()
1304+
FixedOffset::east_opt(0).unwrap().with_ymd_and_hms(1970, 1, 1, 0, 0, 0).unwrap()
13491305
))
13501306
);
13511307
assert_eq!(
13521308
norm(&fixed_from_str("-1").ok().map(DateTime::from)),
13531309
norm(&Some(
1354-
FixedOffset::east_opt(0)
1355-
.unwrap()
1356-
.ymd_opt(1969, 12, 31)
1357-
.unwrap()
1358-
.and_hms_opt(23, 59, 59)
1359-
.unwrap()
1310+
FixedOffset::east_opt(0).unwrap().with_ymd_and_hms(1969, 12, 31, 23, 59, 59).unwrap()
13601311
))
13611312
);
13621313

13631314
assert_eq!(
13641315
*fixed_from_str("0").expect("0 timestamp should parse"),
1365-
Utc.ymd_opt(1970, 1, 1).unwrap().and_hms_opt(0, 0, 0).unwrap()
1316+
Utc.with_ymd_and_hms(1970, 1, 1, 0, 0, 0).unwrap()
13661317
);
13671318
assert_eq!(
13681319
*local_from_str("-1").expect("-1 timestamp should parse"),
1369-
Utc.ymd_opt(1969, 12, 31).unwrap().and_hms_opt(23, 59, 59).unwrap()
1320+
Utc.with_ymd_and_hms(1969, 12, 31, 23, 59, 59).unwrap()
13701321
);
13711322
}

0 commit comments

Comments
 (0)