Index: branches/img_metadata/phase3/includes/media/FormatMetadata.php |
— | — | @@ -99,8 +99,14 @@ |
100 | 100 | continue; |
101 | 101 | } |
102 | 102 | $tags[$tag] = intval( $h[0] / $h[1] ) |
103 | | - . ':' . intval( $m[0] / $m[1] ) |
| 103 | + . ':' . str_pad( intval( $m[0] / $m[1] ), 2, '0', STR_PAD_LEFT ) |
104 | 104 | . ':' . str_pad( intval( $s[0] / $s[1] ), 2, '0', STR_PAD_LEFT ); |
| 105 | + |
| 106 | + $time = wfTimestamp( TS_MW, '1971:01:01 ' . $tags[$tag] ); |
| 107 | + // the 1971:01:01 is just a placeholder, and not shown to user. |
| 108 | + if ( $time ) { |
| 109 | + $tags[$tag] = $wgLang->time( $time ); |
| 110 | + } |
105 | 111 | continue; |
106 | 112 | } |
107 | 113 | |
— | — | @@ -224,18 +230,20 @@ |
225 | 231 | case 'DateTimeMetadata': |
226 | 232 | if ( $val == '0000:00:00 00:00:00' || $val == ' : : : : ' ) { |
227 | 233 | $val = wfMsg( 'exif-unknowndate' ); |
228 | | - } elseif ( preg_match( '/^(?:\d{4}):(?:\d\d):(?:\d\d) (?:\d\d):(?:\d\d):(?:\d\d)$/', $val ) ) { |
229 | | - $val = $wgLang->timeanddate( wfTimestamp( TS_MW, $val ) ); |
230 | | - } elseif ( preg_match( '/^(?:\d{4}):(?:\d\d):(?:\d\d)$/', $val ) ) { |
231 | | - // avoid using wfTimestamp here for the pre-1902 photos |
232 | | - // due to reverse y2k38 bug. $wgLang->timeanddate() is also |
233 | | - // broken on dates from before 1902 so don't worry about it |
234 | | - // in the above case (not to mention that most photos from the |
235 | | - // 1800's don't have a time recorded anyways). |
236 | | - $val = $wgLang->date( substr( $val, 0, 4 ) |
| 234 | + } elseif ( preg_match( '/^(?:\d{4}):(?:\d\d):(?:\d\d) (?:\d\d):(?:\d\d):(?:\d\d)$/D', $val ) ) { |
| 235 | + $time = wfTimestamp( TS_MW, $val ); |
| 236 | + if ( $time ) { |
| 237 | + $val = $wgLang->timeanddate( $time ); |
| 238 | + } |
| 239 | + } elseif ( preg_match( '/^(?:\d{4}):(?:\d\d):(?:\d\d)$/D', $val ) ) { |
| 240 | + // If only the date but not the time is filled in. |
| 241 | + $time = wfTimestamp( TS_MW, substr( $val, 0, 4 ) |
237 | 242 | . substr( $val, 5, 2 ) |
238 | 243 | . substr( $val, 8, 2 ) |
239 | 244 | . '000000' ); |
| 245 | + if ( $time ) { |
| 246 | + $val = $wgLang->date( $time ); |
| 247 | + } |
240 | 248 | } |
241 | 249 | // else it will just output $val without formatting it. |
242 | 250 | break; |
Index: branches/img_metadata/phase3/includes/media/IPTC.php |
— | — | @@ -371,15 +371,12 @@ |
372 | 372 | return null; |
373 | 373 | } |
374 | 374 | |
375 | | - if ( substr($date, 0, 4) < "1902" ) { |
376 | | - // We run into the reverse y2k38 bug. |
377 | | - // Avoid using wfTimestamp as it doesn't work for pre-1902 dates |
378 | | - return substr( $date, 0, 4 ) . ':' |
379 | | - . substr( $date, 4, 2 ) . ':' |
380 | | - . substr( $date, 6, 2 ); |
| 375 | + $unixTS = wfTimestamp( TS_UNIX, $date . substr( $time, 0, 6 )); |
| 376 | + if ( $unixTS === false ) { |
| 377 | + wfDebugLog( 'iptc', "IPTC: can't convert date to TS_UNIX: $date $time." ); |
| 378 | + return null; |
381 | 379 | } |
382 | | - |
383 | | - $unixTS = wfTimestamp( TS_UNIX, $date . substr( $time, 0, 6 )); |
| 380 | + |
384 | 381 | $tz = ( intval( substr( $time, 7, 2 ) ) *60*60 ) |
385 | 382 | + ( intval( substr( $time, 9, 2 ) ) * 60 ); |
386 | 383 | |
— | — | @@ -388,6 +385,10 @@ |
389 | 386 | } |
390 | 387 | |
391 | 388 | $finalTimestamp = wfTimestamp( TS_EXIF, $unixTS + $tz ); |
| 389 | + if ( $finalTimestamp === false ) { |
| 390 | + wfDebugLog( 'iptc', "IPTC: can't make final timestamp. Date: " . ( $unixTS + $tz ) ); |
| 391 | + return null; |
| 392 | + } |
392 | 393 | if ( $dateOnly ) { |
393 | 394 | //return the date only |
394 | 395 | return substr( $finalTimestamp, 0, 10 ); |
Index: branches/img_metadata/phase3/includes/media/XMPValidate.php |
— | — | @@ -234,9 +234,7 @@ |
235 | 235 | //Extra check for empty string necessary due to TZ but no second case. |
236 | 236 | $res[6] = isset( $res[6] ) && $res[6] != '' ? $res[6] : '00'; |
237 | 237 | |
238 | | - if ( !isset( $res[7] ) || $res[7] === 'Z' || $res[1] >= '2038' || $res[1] < '1902' ) { |
239 | | - // timezone processing has y2k38 problem so pretend not set if |
240 | | - // before 1902 or after 2037. |
| 238 | + if ( !isset( $res[7] ) || $res[7] === 'Z' ) { |
241 | 239 | $val = $res[1] . ':' . $res[2] . ':' . $res[3] |
242 | 240 | . ' ' . $res[4] . ':' . $res[5] . ':' . $res[6]; |
243 | 241 | return; |