@@ -103,19 +103,6 @@ public function field_callback( $arguments ) {
103
103
* error log.
104
104
*/
105
105
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
-
119
106
$ url = EVENTS_URL ;
120
107
$ result = file_get_contents ( $ url );
121
108
$ events = json_decode ( $ result , true );
@@ -132,14 +119,18 @@ public static function pull_events( $confirm = false ) {
132
119
$ calendar_id = $ val ['event ' ]['event_instances ' ][0 ]['event_instance ' ]['id ' ];
133
120
$ start = strtotime ( $ val ['event ' ]['event_instances ' ][0 ]['event_instance ' ]['start ' ] );
134
121
$ 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 ' );
136
125
$ end = '' ;
137
126
$ enddate = '' ;
138
127
$ endtime = '' ;
139
128
if ( isset ( $ val ['event ' ]['event_instances ' ][0 ]['event_instance ' ]['end ' ] ) ) {
140
129
$ end = strtotime ( $ val ['event ' ]['event_instances ' ][0 ]['event_instance ' ]['end ' ] );
141
130
$ 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 ' );
143
134
}
144
135
}
145
136
if ( isset ( $ val ['event ' ]['localist_url ' ] ) ) {
0 commit comments