Code Duplication    Length = 32-32 lines in 2 locations

classes/fields/time.php 1 location

@@ 180-211 (lines=32) @@
177
	 * @return string
178
	 * @since  2.7
179
	 */
180
	public function format_time( $options, $js = false ) {
181
182
		switch ( (string) pods_v( static::$type . '_type', $options, '12', true ) ) {
183
			case '12':
184
				$time_format = $this->get_time_formats( $js );
185
				$format      = $time_format[ pods_v( static::$type . '_format', $options, 'hh_mm', true ) ];
186
				break;
187
			case '24':
188
				$time_format_24 = $this->get_time_formats_24( $js );
189
				$format         = $time_format_24[ pods_v( static::$type . '_format_24', $options, 'hh_mm', true ) ];
190
				break;
191
			case 'custom':
192
				if ( ! $js ) {
193
					$format = pods_v( static::$type . '_format_custom', $options, '' );
194
				} else {
195
					$format = pods_v( static::$type . '_format_custom_js', $options, '' );
196
					if ( empty( $format ) ) {
197
						$format = pods_v( static::$type . '_format_custom', $options, '' );
198
						$format = $this->convert_format( $format, array( 'source' => 'php' ) );
199
					}
200
				}
201
				break;
202
			default:
203
				$format = get_option( 'time_format' );
204
				if ( $js ) {
205
					$format = $this->convert_format( $format, array( 'source' => 'php' ) );
206
				}
207
				break;
208
		}//end switch
209
210
		return $format;
211
	}
212
}
213

classes/fields/datetime.php 1 location

@@ 494-525 (lines=32) @@
491
	 *
492
	 * @return string
493
	 */
494
	public function format_time( $options, $js = false ) {
495
496
		switch ( (string) pods_v( static::$type . '_time_type', $options, '12', true ) ) {
497
			case '12':
498
				$time_format = $this->get_time_formats( $js );
499
				$format      = $time_format[ pods_v( static::$type . '_time_format', $options, 'hh_mm', true ) ];
500
				break;
501
			case '24':
502
				$time_format_24 = $this->get_time_formats_24( $js );
503
				$format         = $time_format_24[ pods_v( static::$type . '_time_format_24', $options, 'hh_mm', true ) ];
504
				break;
505
			case 'custom':
506
				if ( ! $js ) {
507
					$format = pods_v( static::$type . '_time_format_custom', $options, '' );
508
				} else {
509
					$format = pods_v( static::$type . '_time_format_custom_js', $options, '' );
510
					if ( empty( $format ) ) {
511
						$format = pods_v( static::$type . '_time_format_custom', $options, '' );
512
						$format = $this->convert_format( $format, array( 'source' => 'php' ) );
513
					}
514
				}
515
				break;
516
			default:
517
				$format = get_option( 'time_format' );
518
				if ( $js ) {
519
					$format = $this->convert_format( $format, array( 'source' => 'php' ) );
520
				}
521
				break;
522
		}//end switch
523
524
		return $format;
525
	}
526
527
	/**
528
	 * Get the date formats.