"UTC-5", 5.5 => "UTC+5:30", 5.75 => "UTC+5:45". */ public function offset_label(): string { $raw = get_option( 'gmt_offset', 0 ); $offset = is_numeric( $raw ) ? (float) $raw : 0.0; $hours = (int) $offset; $minutes = (int) round( abs( $offset - (float) $hours ) * 60.0 ); $sign = $offset < 0 ? '-' : '+'; $label = sprintf( 'UTC%s%d', $sign, abs( $hours ) ); if ( $minutes !== 0 ) { $label .= sprintf( ':%02d', $minutes ); } return $label; } /** * Human-readable description of the timezone events are interpreted in. * * Suitable for Site Health info and the import preview. */ public function effective_label(): string { if ( ! $this->is_fixed_offset() ) { $tz_string = get_option( 'timezone_string', '' ); return is_string( $tz_string ) ? $tz_string : ''; } return sprintf( /* translators: %s is a UTC offset such as "UTC-5". */ __( '%s (fixed offset, no daylight saving)', 'agenticdaisy-calendar' ), $this->offset_label() ); } /** * The admin notice HTML, or an empty string when the timezone is a named zone. */ public function notice_html(): string { if ( ! $this->is_fixed_offset() ) { return ''; } $message = sprintf( /* translators: %s is a UTC offset such as "UTC-5". */ __( 'Your site timezone is set to a fixed offset (%s), which cannot follow daylight saving time. If your region observes daylight saving, imported event times will be off by an hour for part of the year.', 'agenticdaisy-calendar' ), $this->offset_label() ); $remedy = __( 'Choose a city (for example "New York") instead of a UTC offset. Times already imported keep the offset they were saved with, so fix the setting before importing.', 'agenticdaisy-calendar' ); $link_url = admin_url( 'options-general.php' ); $link_text = __( 'Open General Settings', 'agenticdaisy-calendar' ); return sprintf( '
', esc_html__( 'Calendar timezone:', 'agenticdaisy-calendar' ), esc_html( $message ), esc_html( $remedy ), esc_url( $link_url ), esc_html( $link_text ) ); } /** * Echo the admin notice. No output when the timezone is a named zone. */ public function render_notice(): void { // notice_html() escapes every interpolated value. echo $this->notice_html(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped } }