@@ -796,22 +796,24 @@ export const TYPE_SCHEDULE = {
796
796
customizations : GALA_SWITCHOVER_DAY ,
797
797
} ;
798
798
799
+ function adjustDateForUTCAndSwitch ( date ) {
800
+ const checkDate = new Date ( date . getTime ( ) + date . getTimezoneOffset ( ) * 60000 ) ;
801
+ checkDate . setHours ( checkDate . getHours ( ) - SWITCHOVER_TIME ) ;
802
+ return checkDate ;
803
+ }
804
+
799
805
function getDay ( date ) {
800
806
if ( date === undefined ) {
801
807
return 0 ;
802
808
}
803
- const checkDate = new Date ( date . getTime ( ) ) ;
804
- checkDate . setHours ( checkDate . getHours ( ) - SWITCHOVER_TIME ) ;
805
- return checkDate . getDate ( ) ;
809
+ return adjustDateForUTCAndSwitch ( date ) . getDate ( ) ;
806
810
}
807
811
808
812
function getMonth ( date ) {
809
813
if ( date === undefined ) {
810
814
return 0 ;
811
815
}
812
- const checkDate = new Date ( date . getTime ( ) ) ;
813
- checkDate . setHours ( checkDate . getHours ( ) - SWITCHOVER_TIME ) ;
814
- return checkDate . getMonth ( ) ;
816
+ return adjustDateForUTCAndSwitch ( date ) . getMonth ( ) ;
815
817
}
816
818
817
819
function getGalaIndex ( date ) {
@@ -919,8 +921,7 @@ export function getAllScheduleMatchingGroups (date) {
919
921
// subtract switchover time for the matcher classes, but
920
922
// NOT to decide which matchers to assemble.
921
923
// assembly uses getDate and getMonth which already adjust for switchover time
922
- const adjustedDate = new Date ( checkedDate . getTime ( ) ) ;
923
- adjustedDate . setHours ( adjustedDate . getHours ( ) - SWITCHOVER_TIME ) ;
924
+ const adjustedDate = adjustDateForUTCAndSwitch ( checkedDate ) ;
924
925
assembleScheduledMatchers ( checkedDate ) . forEach ( matcher => {
925
926
if ( ! cachedScheduleMatchers [ matcher . type ] ) {
926
927
cachedScheduleMatchers [ matcher . type ] = makeMatcherClass ( adjustedDate ) ;
0 commit comments