File tree Expand file tree Collapse file tree 2 files changed +8
-9
lines changed Expand file tree Collapse file tree 2 files changed +8
-9
lines changed Original file line number Diff line number Diff line change @@ -240,9 +240,10 @@ impl LSPSDateTime {
240
240
now_seconds_since_epoch > datetime_seconds_since_epoch
241
241
}
242
242
243
- /// Returns the time in seconds since the unix epoch.
244
- pub fn abs_diff ( & self , other : & Self ) -> u64 {
245
- self . 0 . timestamp ( ) . abs_diff ( other. 0 . timestamp ( ) )
243
+ /// Returns the absolute difference between two datetimes as a `Duration`.
244
+ pub fn duration_since ( & self , other : & Self ) -> Duration {
245
+ let diff_secs = self . 0 . timestamp ( ) . abs_diff ( other. 0 . timestamp ( ) ) ;
246
+ Duration :: from_secs ( diff_secs)
246
247
}
247
248
248
249
/// Returns the time in seconds since the unix epoch.
Original file line number Diff line number Diff line change @@ -156,7 +156,7 @@ where
156
156
let should_prune = {
157
157
let last_pruning = self . last_pruning . lock ( ) . unwrap ( ) ;
158
158
last_pruning. as_ref ( ) . map_or ( true , |last_time| {
159
- now. abs_diff ( & last_time) > PRUNE_STALE_WEBHOOKS_INTERVAL_DAYS . as_secs ( )
159
+ now. duration_since ( & last_time) > PRUNE_STALE_WEBHOOKS_INTERVAL_DAYS
160
160
} )
161
161
} ;
162
162
@@ -428,10 +428,8 @@ where
428
428
webhook
429
429
. last_notification_sent
430
430
. get ( & notification. method )
431
- . map ( |last_sent| now. abs_diff ( & last_sent) )
432
- . map_or ( false , |duration| {
433
- duration < DEFAULT_NOTIFICATION_COOLDOWN_HOURS . as_secs ( )
434
- } )
431
+ . map ( |last_sent| now. duration_since ( & last_sent) )
432
+ . map_or ( false , |duration| duration < DEFAULT_NOTIFICATION_COOLDOWN_HOURS )
435
433
} ) ;
436
434
437
435
if rate_limit_applies {
@@ -505,7 +503,7 @@ where
505
503
webhooks. retain ( |client_id, client_webhooks| {
506
504
if !self . client_has_open_channel ( client_id) {
507
505
client_webhooks. retain ( |_, webhook| {
508
- now. abs_diff ( & webhook. last_used ) < MIN_WEBHOOK_RETENTION_DAYS . as_secs ( )
506
+ now. duration_since ( & webhook. last_used ) < MIN_WEBHOOK_RETENTION_DAYS
509
507
} ) ;
510
508
!client_webhooks. is_empty ( )
511
509
} else {
You can’t perform that action at this time.
0 commit comments