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<
545545 * the controller state.
546546 */
547547 #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 ( ) ;
552549
553550 for ( const event of events ) {
554551 if ( this . #timers. has ( event . id ) ) {
@@ -557,10 +554,11 @@ export class CronjobController extends BaseController<
557554 continue ;
558555 }
559556
560- const eventDate = DateTime . fromISO ( event . date )
557+ const eventDate = DateTime . fromISO ( event . date , {
558+ setZone : true ,
559+ } )
561560 . toUTC ( )
562- . startOf ( 'second' )
563- . toSeconds ( ) ;
561+ . toMillis ( ) ;
564562
565563 // If the event is recurring and the date is in the past, execute it
566564 // immediately.
@@ -576,16 +574,14 @@ export class CronjobController extends BaseController<
576574 * Clear non-recurring events that are past their scheduled time.
577575 */
578576 #clear( ) {
579- const now = DateTime . fromJSDate ( new Date ( ) )
580- . toUTC ( )
581- . startOf ( 'second' )
582- . toSeconds ( ) ;
577+ const now = Date . now ( ) ;
583578
584579 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+ } )
586583 . toUTC ( )
587- . startOf ( 'second' )
588- . toSeconds ( ) ;
584+ . toMillis ( ) ;
589585
590586 if ( ! event . recurring && eventDate < now ) {
591587 this . #cancel( event . id ) ;
You can’t perform that action at this time.
0 commit comments