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; }
function validateAndConvertToISO($value) { if (strpos($value, "|") !== false) { // temporal encoded date return 'Temporal'; } else { //$date = parseDateTime($value); //return @$date['year'].'-'.@$date['month'].'-'.@$date['day']; return removeLeadingYearZeroes($value, false, true); } }