Skip to content

Commit fca9c27

Browse files
fixup: add timestamp and now helpers to LSPSDateTime
Add helper methods to LSPSDateTime that return the timestamp as seconds and as milliseconds since the Unix epoch. These methods improve consistency in date-time conversions.
1 parent 1774ec1 commit fca9c27

File tree

1 file changed

+11
-0
lines changed
  • lightning-liquidity/src/lsps0

1 file changed

+11
-0
lines changed

lightning-liquidity/src/lsps0/ser.rs

+11
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,17 @@ impl LSPSDateTime {
235235
self.0.timestamp().try_into().expect("expiration to be ahead of unix epoch");
236236
now_seconds_since_epoch > datetime_seconds_since_epoch
237237
}
238+
239+
/// Returns the timestamp as seconds since the Unix epoch.
240+
pub fn timestamp(&self) -> i64 {
241+
self.0.timestamp()
242+
}
243+
244+
/// Returns the timestamp as milliseconds since the Unix epoch.
245+
pub fn now() -> Self {
246+
Self(chrono::Utc::now())
247+
}
248+
238249
}
239250

240251
impl FromStr for LSPSDateTime {

0 commit comments

Comments
 (0)