Code Duplication    Length = 15-15 lines in 2 locations

core/helpers/EEH_DTT_Helper.helper.php 1 location

@@ 140-154 (lines=15) @@
137
        $gmt_offset =  (int) $gmt_offset;
138
        /** @var array[] $abbreviations */
139
        $abbreviations = DateTimeZone::listAbbreviations();
140
        foreach ($abbreviations as $abbreviation) {
141
            foreach ($abbreviation as $timezone) {
142
                if ((int) $timezone['offset'] === $gmt_offset && (bool) $timezone['dst'] === false) {
143
                    try {
144
                        $offset = self::get_timezone_offset(new DateTimeZone($timezone['timezone_id']));
145
                        if ($offset !== $gmt_offset) {
146
                            continue;
147
                        }
148
                        return $timezone['timezone_id'];
149
                    } catch (Exception $e) {
150
                        continue;
151
                    }
152
                }
153
            }
154
        }
155
        //if $coerce is true, let's see if we can get a timezone string after the offset is adjusted
156
        if ($coerce === true) {
157
            $timezone_string = self::get_timezone_string_from_abbreviations_list(

core/services/helpers/datetime/PhpCompatLessFiveSixHelper.php 1 location

@@ 94-108 (lines=15) @@
91
        $gmt_offset = (int)$gmt_offset;
92
        /** @var array[] $abbreviations */
93
        $abbreviations = DateTimeZone::listAbbreviations();
94
        foreach ($abbreviations as $abbreviation) {
95
            foreach ($abbreviation as $timezone) {
96
                if ((int)$timezone['offset'] === $gmt_offset && (bool)$timezone['dst'] === false) {
97
                    try {
98
                        $offset = $this->getTimezoneOffset(new DateTimeZone($timezone['timezone_id']));
99
                        if ($offset !== $gmt_offset) {
100
                            continue;
101
                        }
102
                        return $timezone['timezone_id'];
103
                    } catch (Exception $e) {
104
                        continue;
105
                    }
106
                }
107
            }
108
        }
109
        //if $coerce is true, let's see if we can get a timezone string after the offset is adjusted
110
        if ($coerce === true) {
111
            $timezone_string = $this->getTimezoneStringFromAbbreviationsList(