r69492 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r69491‎ | r69492 | r69493 >
Date:23:29, 17 July 2010
Author:bawolff
Status:ok (Comments)
Tags:
Comment:
Let wfTimestamp recognize negative unix timestamp values
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/GlobalFunctions.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/GlobalFunctions.php
@@ -1892,7 +1892,7 @@
18931893 # TS_EXIF
18941894 } elseif (preg_match('/^(\d{4})(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)$/D',$ts,$da)) {
18951895 # TS_MW
1896 - } elseif (preg_match('/^\d{1,13}$/D',$ts)) {
 1896+ } elseif (preg_match('/^-?\d{1,13}$/D',$ts)) {
18971897 # TS_UNIX
18981898 $uts = $ts;
18991899 } elseif (preg_match('/^\d{2}-\d{2}-\d{4} \d{2}:\d{2}:\d{2}.\d{6}$/', $ts)) {
Index: trunk/phase3/RELEASE-NOTES
@@ -241,6 +241,7 @@
242242 * (bug 24076) Recognize Office 2003 files with OpenXML trailers
243243 * (bug 24244) Updated comments in DefaultSettings.php to reflect Image: --> File:
244244 namespace rename.
 245+* Make wfTimestamp recognize negative unix timestamp values.
245246
246247 === API changes in 1.17 ===
247248 * (bug 22738) Allow filtering by action type on query=logevent.

Comments

#Comment by Nikerabbit (talk | contribs)   06:35, 18 July 2010

I can see that from the commit, but not why?

#Comment by Platonides (talk | contribs)   12:40, 18 July 2010

Why?

#Comment by Catrope (talk | contribs)   12:44, 18 July 2010
[22:57:30] <bawolff>	hmm, $wgLang->timeanddate($time) doesn't seem to work if $time is pre-unix epoch
[23:01:02] <RoanKattouw>	bawolff: As in, negative? What does wfTimestamp(TS_MW, $time) do?
[23:01:52] <bawolff>	hmm, let me check
[23:02:59] <bawolff>	appears as if wfTimestamp is the problem rather than the dateandtime function
[23:03:35] <bawolff>	if wfTimestamp(TS_MW, $time) with $time being negative give jan 1 1970
#Comment by Bawolff (talk | contribs)   21:30, 18 July 2010

I was testing some code in my working copy related to extracting dates from iptc metadata. Anyways my code was failing on File:Bundesarchiv Bild 183-18379-0003, Erich Hansen, Kirchner, Feist, Oswald Schelter.jpg because the creation date was 16 February 1953 which is before 1970. I figured it couldn't hurt anything for wfTimestamp to accept negative unix timestamp dates. I'd still run in to problems if any image was from before about 1902, but that seems much less likely.

Status & tagging log