@@ -30,6 +30,7 @@ use crate::naive::{Days, IsoWeek, NaiveDate, NaiveDateTime, NaiveTime};
30
30
use crate :: offset:: Local ;
31
31
use crate :: offset:: { FixedOffset , Offset , TimeZone , Utc } ;
32
32
use crate :: oldtime:: Duration as OldDuration ;
33
+ #[ allow( deprecated) ]
33
34
use crate :: Date ;
34
35
use crate :: Months ;
35
36
use crate :: { Datelike , Timelike , Weekday } ;
@@ -167,8 +168,8 @@ impl<Tz: TimeZone> DateTime<Tz> {
167
168
/// ```
168
169
/// use chrono::prelude::*;
169
170
///
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();
172
173
/// assert_eq!(date.date_naive(), other.date_naive());
173
174
/// ```
174
175
#[ inline]
@@ -201,13 +202,12 @@ impl<Tz: TimeZone> DateTime<Tz> {
201
202
/// # Example
202
203
///
203
204
/// ```
204
- /// use chrono::Utc;
205
- /// use chrono::TimeZone;
205
+ /// use chrono::{Utc, TimeZone, NaiveDate};
206
206
///
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();
208
208
/// assert_eq!(dt.timestamp_millis(), 1_444);
209
209
///
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();
211
211
/// assert_eq!(dt.timestamp_millis(), 1_000_000_000_555);
212
212
/// ```
213
213
#[ inline]
@@ -225,13 +225,12 @@ impl<Tz: TimeZone> DateTime<Tz> {
225
225
/// # Example
226
226
///
227
227
/// ```
228
- /// use chrono::Utc;
229
- /// use chrono::TimeZone;
228
+ /// use chrono::{Utc, TimeZone, NaiveDate};
230
229
///
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();
232
231
/// assert_eq!(dt.timestamp_micros(), 1_000_444);
233
232
///
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();
235
234
/// assert_eq!(dt.timestamp_micros(), 1_000_000_000_000_555);
236
235
/// ```
237
236
#[ inline]
@@ -249,13 +248,12 @@ impl<Tz: TimeZone> DateTime<Tz> {
249
248
/// # Example
250
249
///
251
250
/// ```
252
- /// use chrono::Utc;
253
- /// use chrono::TimeZone;
251
+ /// use chrono::{Utc, TimeZone, NaiveDate};
254
252
///
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();
256
254
/// assert_eq!(dt.timestamp_nanos(), 1_000_000_444);
257
255
///
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();
259
257
/// assert_eq!(dt.timestamp_nanos(), 1_000_000_000_000_000_555);
260
258
/// ```
261
259
#[ inline]
@@ -529,10 +527,10 @@ impl DateTime<FixedOffset> {
529
527
/// representation of times in HTTP and email headers.
530
528
///
531
529
/// ```
532
- /// # use chrono::{DateTime, FixedOffset, TimeZone};
530
+ /// # use chrono::{DateTime, FixedOffset, TimeZone, NaiveDate };
533
531
/// assert_eq!(
534
532
/// 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()
536
534
/// );
537
535
/// ```
538
536
pub fn parse_from_rfc2822 ( s : & str ) -> ParseResult < DateTime < FixedOffset > > {
@@ -570,11 +568,11 @@ impl DateTime<FixedOffset> {
570
568
/// # Example
571
569
///
572
570
/// ```rust
573
- /// use chrono::{DateTime, FixedOffset, TimeZone};
571
+ /// use chrono::{DateTime, FixedOffset, TimeZone, NaiveDate };
574
572
///
575
573
/// let dt = DateTime::parse_from_str(
576
574
/// "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()));
578
576
/// ```
579
577
pub fn parse_from_str ( s : & str , fmt : & str ) -> ParseResult < DateTime < FixedOffset > > {
580
578
let mut parsed = Parsed :: new ( ) ;
@@ -617,8 +615,8 @@ where
617
615
/// # Examples
618
616
///
619
617
/// ```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();
622
620
/// assert_eq!(dt.to_rfc3339_opts(SecondsFormat::Millis, false),
623
621
/// "2018-01-26T18:30:09.453+00:00");
624
622
/// assert_eq!(dt.to_rfc3339_opts(SecondsFormat::Millis, true),
@@ -627,7 +625,7 @@ where
627
625
/// "2018-01-26T18:30:09Z");
628
626
///
629
627
/// 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();
631
629
/// assert_eq!(dt.to_rfc3339_opts(SecondsFormat::Secs, true),
632
630
/// "2018-01-26T10:30:09+08:00");
633
631
/// ```
@@ -696,7 +694,7 @@ where
696
694
/// ```rust
697
695
/// use chrono::prelude::*;
698
696
///
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();
700
698
/// let formatted = format!("{}", date_time.format("%d/%m/%Y %H:%M"));
701
699
/// assert_eq!(formatted, "02/04/2017 12:50");
702
700
/// ```
@@ -880,8 +878,8 @@ impl<Tz: TimeZone, Tz2: TimeZone> PartialOrd<DateTime<Tz2>> for DateTime<Tz> {
880
878
/// ```
881
879
/// use chrono::prelude::*;
882
880
///
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());
885
883
///
886
884
/// assert_eq!(earlier.to_string(), "2015-05-15 01:00:00 -01:00");
887
885
/// assert_eq!(later.to_string(), "2015-05-14 22:00:00 -05:00");
@@ -1166,47 +1164,27 @@ where
1166
1164
1167
1165
#[ test]
1168
1166
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( ) ) ;
1174
1169
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( ) ) ;
1184
1173
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( ) ) ;
1190
1176
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( ) ) ;
1200
1180
}
1201
1181
1202
1182
#[ test]
1203
1183
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 ( ) ;
1205
1185
let cdt_dt = FixedOffset :: west_opt ( 5 * 60 * 60 )
1206
1186
. 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 )
1210
1188
. unwrap ( ) ;
1211
1189
let utc_dt2: DateTime < Utc > = cdt_dt. into ( ) ;
1212
1190
assert_eq ! ( utc_dt, utc_dt2) ;
@@ -1220,30 +1198,20 @@ where
1220
1198
E : :: core:: fmt:: Debug ,
1221
1199
{
1222
1200
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( ) ,
1224
1202
Some ( r#""2014-07-24T12:34:06Z""# . into( ) )
1225
1203
) ;
1226
1204
1227
1205
assert_eq ! (
1228
1206
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( )
1235
1208
)
1236
1209
. ok( ) ,
1237
1210
Some ( r#""2014-07-24T12:34:06+01:01""# . into( ) )
1238
1211
) ;
1239
1212
assert_eq ! (
1240
1213
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( )
1247
1215
)
1248
1216
. ok( ) ,
1249
1217
Some ( r#""2014-07-24T12:34:06+01:00:50""# . into( ) )
@@ -1268,32 +1236,25 @@ fn test_decodable_json<FUtc, FFixed, FLocal, E>(
1268
1236
1269
1237
assert_eq ! (
1270
1238
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( ) ) )
1272
1240
) ;
1273
1241
assert_eq ! (
1274
1242
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( ) ) )
1276
1244
) ;
1277
1245
1278
1246
assert_eq ! (
1279
1247
norm( & fixed_from_str( r#""2014-07-24T12:34:06Z""# ) . ok( ) ) ,
1280
1248
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( )
1287
1250
) )
1288
1251
) ;
1289
1252
assert_eq ! (
1290
1253
norm( & fixed_from_str( r#""2014-07-24T13:57:06+01:23""# ) . ok( ) ) ,
1291
1254
norm( & Some (
1292
1255
FixedOffset :: east_opt( 60 * 60 + 23 * 60 )
1293
1256
. 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 )
1297
1258
. unwrap( )
1298
1259
) )
1299
1260
) ;
@@ -1302,11 +1263,11 @@ fn test_decodable_json<FUtc, FFixed, FLocal, E>(
1302
1263
// the conversion didn't change the instant itself
1303
1264
assert_eq ! (
1304
1265
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( )
1306
1267
) ;
1307
1268
assert_eq ! (
1308
1269
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( )
1310
1271
) ;
1311
1272
1312
1273
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>(
1330
1291
1331
1292
assert_eq ! (
1332
1293
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( ) ) )
1334
1295
) ;
1335
1296
assert_eq ! (
1336
1297
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( ) ) )
1338
1299
) ;
1339
1300
1340
1301
assert_eq ! (
1341
1302
norm( & fixed_from_str( "0" ) . ok( ) . map( DateTime :: from) ) ,
1342
1303
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( )
1349
1305
) )
1350
1306
) ;
1351
1307
assert_eq ! (
1352
1308
norm( & fixed_from_str( "-1" ) . ok( ) . map( DateTime :: from) ) ,
1353
1309
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( )
1360
1311
) )
1361
1312
) ;
1362
1313
1363
1314
assert_eq ! (
1364
1315
* 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( )
1366
1317
) ;
1367
1318
assert_eq ! (
1368
1319
* 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( )
1370
1321
) ;
1371
1322
}
0 commit comments