@@ -27,7 +27,7 @@ use crate::pow::{verify_size, Difficulty, Proof, ProofOfWork};
27
27
use crate :: ser:: {
28
28
self , deserialize_default, serialize_default, PMMRable , Readable , Reader , Writeable , Writer ,
29
29
} ;
30
- use chrono:: prelude:: { DateTime , NaiveDateTime , Utc } ;
30
+ use chrono:: prelude:: { DateTime , Utc } ;
31
31
use chrono:: Duration ;
32
32
use keychain:: { self , BlindingFactor } ;
33
33
use std:: convert:: TryInto ;
@@ -232,7 +232,7 @@ impl Default for BlockHeader {
232
232
version : HeaderVersion ( 1 ) ,
233
233
height : 0 ,
234
234
timestamp : DateTime :: from_naive_utc_and_offset (
235
- NaiveDateTime :: from_timestamp_opt ( 0 , 0 ) . unwrap ( ) ,
235
+ DateTime :: < Utc > :: from_timestamp ( 0 , 0 ) . unwrap ( ) . naive_utc ( ) ,
236
236
Utc ,
237
237
) ,
238
238
prev_hash : ZERO_HASH ,
@@ -295,25 +295,27 @@ fn read_block_header<R: Reader>(reader: &mut R) -> Result<BlockHeader, ser::Erro
295
295
> chrono:: NaiveDate :: MAX
296
296
. and_hms_opt ( 0 , 0 , 0 )
297
297
. unwrap ( )
298
+ . and_utc ( )
298
299
. timestamp ( )
299
300
|| timestamp
300
301
< chrono:: NaiveDate :: MIN
301
302
. and_hms_opt ( 0 , 0 , 0 )
302
303
. unwrap ( )
304
+ . and_utc ( )
303
305
. timestamp ( )
304
306
{
305
307
return Err ( ser:: Error :: CorruptedData ) ;
306
308
}
307
309
308
- let ts = NaiveDateTime :: from_timestamp_opt ( timestamp, 0 ) ;
310
+ let ts = DateTime :: < Utc > :: from_timestamp ( timestamp, 0 ) ;
309
311
if ts. is_none ( ) {
310
312
return Err ( ser:: Error :: CorruptedData ) ;
311
313
}
312
314
313
315
Ok ( BlockHeader {
314
316
version,
315
317
height,
316
- timestamp : DateTime :: from_naive_utc_and_offset ( ts. unwrap ( ) , Utc ) ,
318
+ timestamp : DateTime :: from_naive_utc_and_offset ( ts. unwrap ( ) . naive_utc ( ) , Utc ) ,
317
319
prev_hash,
318
320
prev_root,
319
321
output_root,
@@ -662,12 +664,12 @@ impl Block {
662
664
663
665
let now = Utc :: now ( ) . timestamp ( ) ;
664
666
665
- let ts = NaiveDateTime :: from_timestamp_opt ( now, 0 ) ;
667
+ let ts = DateTime :: < Utc > :: from_timestamp ( now, 0 ) ;
666
668
if ts. is_none ( ) {
667
669
return Err ( Error :: Other ( "Converting Utc::now() into timestamp" . into ( ) ) ) ;
668
670
}
669
671
670
- let timestamp = DateTime :: from_naive_utc_and_offset ( ts. unwrap ( ) , Utc ) ;
672
+ let timestamp = DateTime :: from_naive_utc_and_offset ( ts. unwrap ( ) . naive_utc ( ) , Utc ) ;
671
673
// Now build the block with all the above information.
672
674
// Note: We have not validated the block here.
673
675
// Caller must validate the block as necessary.
0 commit comments