File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed
lightning-liquidity/src/lsps0 Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ use crate::lsps2::msgs::{
18
18
} ;
19
19
use crate :: prelude:: { HashMap , String } ;
20
20
21
+ use chrono:: DateTime ;
21
22
use lightning:: ln:: msgs:: { DecodeError , LightningError } ;
22
23
use lightning:: ln:: wire;
23
24
use lightning:: util:: ser:: { LengthLimitedRead , LengthReadable , WithoutLength } ;
@@ -27,6 +28,7 @@ use bitcoin::secp256k1::PublicKey;
27
28
use core:: fmt:: { self , Display } ;
28
29
use core:: str:: FromStr ;
29
30
31
+ use core:: time:: Duration ;
30
32
#[ cfg( feature = "std" ) ]
31
33
use std:: time:: { SystemTime , UNIX_EPOCH } ;
32
34
@@ -212,6 +214,17 @@ impl LSPSDateTime {
212
214
self . 0 . timestamp ( ) . try_into ( ) . expect ( "expiration to be ahead of unix epoch" ) ;
213
215
now_seconds_since_epoch > datetime_seconds_since_epoch
214
216
}
217
+
218
+ /// Returns the time in seconds since the unix epoch.
219
+ pub fn abs_diff ( & self , other : & Self ) -> u64 {
220
+ self . 0 . timestamp ( ) . abs_diff ( other. 0 . timestamp ( ) )
221
+ }
222
+ }
223
+
224
+ impl From < Duration > for LSPSDateTime {
225
+ fn from ( duration : Duration ) -> Self {
226
+ Self ( DateTime :: UNIX_EPOCH + duration)
227
+ }
215
228
}
216
229
217
230
impl FromStr for LSPSDateTime {
You can’t perform that action at this time.
0 commit comments