Code Duplication    Length = 32-32 lines in 2 locations

classes/fields/datetime.php 1 location

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

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