File tree Expand file tree Collapse file tree 1 file changed +10
-14
lines changed
packages/snaps-controllers/src/cronjob Expand file tree Collapse file tree 1 file changed +10
-14
lines changed Original file line number Diff line number Diff line change @@ -545,10 +545,7 @@ export class CronjobController extends BaseController<
545
545
* the controller state.
546
546
*/
547
547
#reschedule( events = Object . values ( this . state . events ) ) {
548
- const now = DateTime . fromJSDate ( new Date ( ) )
549
- . toUTC ( )
550
- . startOf ( 'second' )
551
- . toSeconds ( ) ;
548
+ const now = Date . now ( ) ;
552
549
553
550
for ( const event of events ) {
554
551
if ( this . #timers. has ( event . id ) ) {
@@ -557,10 +554,11 @@ export class CronjobController extends BaseController<
557
554
continue ;
558
555
}
559
556
560
- const eventDate = DateTime . fromISO ( event . date )
557
+ const eventDate = DateTime . fromISO ( event . date , {
558
+ setZone : true ,
559
+ } )
561
560
. toUTC ( )
562
- . startOf ( 'second' )
563
- . toSeconds ( ) ;
561
+ . toMillis ( ) ;
564
562
565
563
// If the event is recurring and the date is in the past, execute it
566
564
// immediately.
@@ -576,16 +574,14 @@ export class CronjobController extends BaseController<
576
574
* Clear non-recurring events that are past their scheduled time.
577
575
*/
578
576
#clear( ) {
579
- const now = DateTime . fromJSDate ( new Date ( ) )
580
- . toUTC ( )
581
- . startOf ( 'second' )
582
- . toSeconds ( ) ;
577
+ const now = Date . now ( ) ;
583
578
584
579
for ( const event of Object . values ( this . state . events ) ) {
585
- const eventDate = DateTime . fromISO ( event . date )
580
+ const eventDate = DateTime . fromISO ( event . date , {
581
+ setZone : true ,
582
+ } )
586
583
. toUTC ( )
587
- . startOf ( 'second' )
588
- . toSeconds ( ) ;
584
+ . toMillis ( ) ;
589
585
590
586
if ( ! event . recurring && eventDate < now ) {
591
587
this . #cancel( event . id ) ;
You can’t perform that action at this time.
0 commit comments