Woah! I need to get you SVN access soon :-) ... and, citing from the audio recordings of our Wikimania session: "keep up with the work, it's great" (Sir Tim Berners-Lee on SMW ;-).
I will take care of the merging as soon as I find the time (so many mergings of contribs these days ...) -- Markus On Tuesday 28 November 2006 13:10, S Page wrote: > I noticed in http://ontoworld.org/wiki/Date-related_tables that user > Patrick is trying to display parts of a date. For example, show Jul 6 > as birthday of G.W. Bush whose date of birth is 1946-07-06. > > Inline queries allow passing a unit, e.g. > [[mass:=*oz]] > will show masses in ounces instead of the primary unit (kg). > > So I modified SMW_DT_DateTime.php to take this unit, but interpret it as > a date format string (SMW formats dates using strftime(), > http://us2.php.net/manual/en/function.strftime.php ). Thus > > <ask> > [[date of birth:=+]] > [[date of birth:=*%b %d]] > </ask> > > will show just the month and day part of a Type:Date in "Jul 6" format. > Pretty cool, though still not enough to derive astrological signs of > the zodiac from Date of birth. ;-) > > Someone else has already noted that you can't ask for an attribute twice > in one inline query with two different "units"; this would be nice so > you could have parts of the date in separate columns so you can sort by > time, or birthday, or year. Has a bug been filed for this? > > I currently can't check in to MediaWiki Subversion, but it's a simple > patch (below). > > -- > =S > > > $ svn diff SMW_DT_DateTime.php | expand -4 > Index: SMW_DT_DateTime.php > =================================================================== > --- SMW_DT_DateTime.php (revision 17944) > +++ SMW_DT_DateTime.php (working copy) > @@ -39,6 +39,10 @@ > * @access public > */ > function processValue($v,&$datavalue) { > + // For a DateTime, "units" is really a format from an inline query > + // rather than the units of a float. > + $desiredUnits = $datavalue->getDesiredUnits(); > + //echo "DEBUG: in DateTimeHandler->processValue(), > desiredUnits="; echo implode('|',$desiredUnits); echo "<br />\n"; > $str_val = trim($v); > $time = strtotime($str_val); > if ($time == -1 || $time === false) { > @@ -50,22 +54,33 @@ > // so reformat back to ISO8601. Unfortunatelly, ISO in > // general is not compatible with XSD; but it should work > // for the restricted interval we currently support. > - $str_val = strftime("%Y-%m-%d", $time); > - $user_val = $str_val; > - // See if there is a significant time component. > - // TODO: what about TimeZone?! > - if ( abs($time - strtotime($str_val)) > 0.5) { > - $user_val .= strftime(" %H:%M:%S", $time); > + $date_part = strftime("%Y-%m-%d", $time); > + $str_val = $date_part . strftime("T%H:%M:%S", $time); // always > show time in XSD > + $datavalue->setProcessedValues($v, $str_val, $time); > + > + // Determine the user-visible string. > + if (count($desiredUnits) ==0) { > + // The default user-visible string shows date, plus > + // time of day separated by space if it's significant. > + $user_val = $date_part; > + // See if there is a significant time component. > + // TODO: what about TimeZone?! > + if ( abs($time - strtotime($str_val)) > 0.5) { > + $user_val .= strftime(" %H:%M:%S", $time); > + } > + $datavalue->setPrintoutString($user_val); > + } else { > + // Print the date in all wanted formats (even if some of > them would be equivalent -- we obey the user's wish) > + foreach ($desiredUnits as $wantedFormat) { > + $datavalue->setPrintoutString(strftime($wantedFormat, > $time)); > + } > } > - $str_val .= strftime("T%H:%M:%S", $time); // always show time in > XSD > > - $datavalue->setProcessedValues($v, $str_val, $time); > - $datavalue->setPrintoutString($user_val); > //smwfNumberFormat($time) . ' seconds since 1970' ; > // do not show the seconds since 1970; showing a date in > multiple calendar systems could be a future output enhancement (Roman, > Gregorian, whatever calendar), if the date is "historical" enough > > $datavalue->addQuicksearchLink(); > - $datavalue->addServiceLinks($str_val); //possibly provide single > alues (year, month, ...) in the future > + $datavalue->addServiceLinks($str_val); //possibly provide single > values (year, month, ...) in the future > return; > } > > ------------------------------------------------------------------------- > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to share > your opinions on IT & business topics through brief surveys - and earn cash > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > _______________________________________________ > Semediawiki-devel mailing list > Semediawiki-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/semediawiki-devel -- Markus Krötzsch Institute AIFB, University of Karlsruhe, D-76128 Karlsruhe [EMAIL PROTECTED] phone +49 (0)721 608 7362 www.aifb.uni-karlsruhe.de/WBS/ fax +49 (0)721 693 717
pgpyBnhz9NDfE.pgp
Description: PGP signature
------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________ Semediawiki-devel mailing list Semediawiki-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/semediawiki-devel