function temporalToHumanReadableString($value, $showoriginal_temporal = false) { if (strpos($value, "|") !== false) { // temporal encoded date $value2 = $value; $tDate = array(); $props = explode("|", substr_replace($value2, "", 0, 1)); // remove first verticle bar and create array foreach ($props as $prop) { //create an assoc array list($tag, $val) = explode("=", $prop); $tDate[$tag] = $val; } switch ($tDate["TYP"]) { case 's': //simple if (@$tDate['DAT']) { $value = removeLeadingYearZeroes($tDate['DAT']); } else { $value = "unknown temporal format"; } break; case 'f': //fuzzy if (@$tDate['DAT']) { $value = removeLeadingYearZeroes($tDate['DAT']) . ($tDate['RNG'] ? ' ' . convertDurationToDelta($tDate['RNG'], '±') : ""); } else { $value = "unknown fuzzy temporal format"; } break; case 'c': //carbon $value = @$tDate['BPD'] ? '' . $tDate['BPD'] . ' BPD' : @$tDate['BCE'] ? '' . $tDate['BCE'] . ' BCE' : ""; if ($value) { $value = $value . (@$tDate['DEV'] ? ' ' . convertDurationToDelta($tDate['DEV'], '±') : @$tDate['DVP'] ? ' ' . convertDurationToDelta($tDate['DVP'], '+') . (@$tDate['DVN'] ? "/ " . convertDurationToDelta($tDate['DVN'], '-') : "") : @$tDate['DVN'] ? " " . convertDurationToDelta($tDate['DVN'], '-') : ""); } else { $value = "unknown carbon temporal format"; } break; case 'p': //probability range if (@$tDate['PDB'] && @$tDate['PDE']) { $value = "" . removeLeadingYearZeroes($tDate['PDB']) . " - " . removeLeadingYearZeroes($tDate['PDE']); } else { if (@$tDate['TPQ'] && @$tDate['TAQ']) { $value = "" . removeLeadingYearZeroes($tDate['TPQ']) . " - " . removeLeadingYearZeroes($tDate['TAQ']); } else { $value = "unknown probability range temporal format"; } } break; } if ($showoriginal_temporal) { $value .= " [ {$value2} ]"; } } else { $value = removeLeadingYearZeroes($value); } return $value; }
/** * brief description of file * * @author Tom Murtagh * @author Kim Jackson * @author Ian Johnson <*****@*****.**> * @author Stephen White * @author Artem Osmakov <*****@*****.**> * @copyright (C) 2005-2016 University of Sydney * @link http://HeuristNetwork.org * @version 3.1.0 * @license http://www.gnu.org/licenses/gpl-3.0.txt GNU License 3.0 * @package Heurist academic knowledge management system * @subpackage !!!subpackagename for file such as Administration, Search, Edit, Application, Library */ function temporalToHumanReadableString($value, $showoriginal_temporal = false) { if (strpos($value, "|") !== false) { // temporal encoded date $value2 = $value; $cld = null; $tDate = array(); $props = explode("|", substr_replace($value2, "", 0, 1)); // remove first verticle bar and create array foreach ($props as $prop) { //create an assoc array list($tag, $val) = explode("=", $prop); $tDate[$tag] = $val; } if (@$tDate["CLD"] && @$tDate["CL2"] && strtolower($tDate["CLD"]) != 'gregorian') { $cld = $tDate["CL2"] . " " . $tDate["CLD"]; if (strpos($cld, 'null') !== false) { $cld = substr($cld, 4); } //some dates were saved in wrong format - fix it } $is_greg_or_julian = !@$tDate["CLD"] || strtolower($tDate["CLD"]) == 'gregorian' || strtolower(@$tDate["CLD"]) == 'julian'; switch ($tDate["TYP"]) { case 's': //simple if (@$tDate['DAT']) { $value = removeLeadingYearZeroes($tDate['DAT'], $is_greg_or_julian); } else { $value = "unknown temporal format"; } break; case 'f': //fuzzy if (@$tDate['DAT']) { $value = removeLeadingYearZeroes($tDate['DAT'], $is_greg_or_julian) . ($tDate['RNG'] ? ' ' . convertDurationToDelta($tDate['RNG'], '±') : ""); } else { $value = "unknown fuzzy temporal format"; } break; case 'c': //carbon $value = @$tDate['BPD'] ? '' . $tDate['BPD'] . ' BPD' : @$tDate['BCE'] ? '' . $tDate['BCE'] . ' BCE' : ""; if ($value) { $value = $value . (@$tDate['DEV'] ? ' ' . convertDurationToDelta($tDate['DEV'], '±') : (@$tDate['DVP'] ? ' ' . convertDurationToDelta($tDate['DVP'], '+') . (@$tDate['DVN'] ? "/ " . convertDurationToDelta($tDate['DVN'], '-') : "") : (@$tDate['DVN'] ? " " . convertDurationToDelta($tDate['DVN'], '-') : ""))); } else { $value = "unknown carbon temporal format"; } break; case 'p': //probability range if (@$tDate['PDB'] && @$tDate['PDE']) { $value = "" . removeLeadingYearZeroes($tDate['PDB'], $is_greg_or_julian) . " to " . removeLeadingYearZeroes($tDate['PDE'], $is_greg_or_julian); } else { if (@$tDate['TPQ'] && @$tDate['TAQ']) { $value = "" . removeLeadingYearZeroes($tDate['TPQ'], $is_greg_or_julian) . " to " . removeLeadingYearZeroes($tDate['TAQ'], $is_greg_or_julian); } else { $value = "unknown probability range temporal format"; } } break; } if ($cld) { $value = $cld . ' (Gregorian ' . $value . ')'; } if ($showoriginal_temporal) { $value .= " [ {$value2} ]"; } } else { $value = removeLeadingYearZeroes($value); } return $value; }