@@ -103,19 +103,6 @@ public function field_callback( $arguments ) {
103103 * error log.
104104 */
105105 public static function pull_events ( $ confirm = false ) {
106-
107- /**
108- * Before we do anything, make sure our timezone is set correctly based on
109- * the site settings. Ideally we would store times and dates in their proper
110- * format, but it was a legacy decision that they would be stored as
111- * strings, rather than datetimes.
112- *
113- * TODO: Fix this more fundamentally.
114- */
115- // phpcs:disable WordPress.DateTime.RestrictedFunctions.timezone_change_date_default_timezone_set -- temporarily ignore this problem.
116- date_default_timezone_set ( get_option ( 'timezone_string ' ) );
117- // phpcs:enable -- begin scanning normally again.
118-
119106 $ url = EVENTS_URL ;
120107 $ result = file_get_contents ( $ url );
121108 $ events = json_decode ( $ result , true );
@@ -132,14 +119,18 @@ public static function pull_events( $confirm = false ) {
132119 $ calendar_id = $ val ['event ' ]['event_instances ' ][0 ]['event_instance ' ]['id ' ];
133120 $ start = strtotime ( $ val ['event ' ]['event_instances ' ][0 ]['event_instance ' ]['start ' ] );
134121 $ startdate = gmdate ( 'Ymd ' , $ start );
135- $ starttime = gmdate ( 'h:i A ' , $ start );
122+ $ workingtime = new DateTime ( gmdate ( 'h:i A ' , $ start ) );
123+ $ workingtime ->setTimezone ( new DateTimeZone ( get_option ( 'timezone_string ' ) ) );
124+ $ starttime = $ workingtime ->format ( 'h:i A ' );
136125 $ end = '' ;
137126 $ enddate = '' ;
138127 $ endtime = '' ;
139128 if ( isset ( $ val ['event ' ]['event_instances ' ][0 ]['event_instance ' ]['end ' ] ) ) {
140129 $ end = strtotime ( $ val ['event ' ]['event_instances ' ][0 ]['event_instance ' ]['end ' ] );
141130 $ enddate = gmdate ( 'Ymd ' , $ end );
142- $ endtime = gmdate ( 'h:i A ' , $ end );
131+ $ workingtime = new DateTime ( gmdate ( 'h:i A ' , $ end ) );
132+ $ workingtime ->setTimezone ( new DateTimeZone ( get_option ( 'timezone_string ' ) ) );
133+ $ endtime = $ workingtime ->format ( 'h:i A ' );
143134 }
144135 }
145136 if ( isset ( $ val ['event ' ]['localist_url ' ] ) ) {
0 commit comments