+ */
+final class t3lib_utility_Date {
+
+
+ /**
+ * Returns the difference in days between input $tstamp and $EXEC_TIME
+ * Usage: 2 (class t3lib_BEfunc)
+ *
+ * @param integer Time stamp, seconds
+ * @return integer
+ */
+ public static function daysUntil($tstamp) {
+ $delta_t = $tstamp-$GLOBALS['EXEC_TIME'];
+ return ceil($delta_t/(3600*24));
+ }
+
+ /**
+ * Returns $tstamp formatted as "ddmmyy" (According to $TYPO3_CONF_VARS['SYS']['ddmmyy'])
+ * Usage: 11
+ *
+ * @param integer Time stamp, seconds
+ * @return string Formatted time
+ */
+ public static function date($tstamp) {
+ return date($GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'], (int)$tstamp);
+ }
+
+ /**
+ * Returns $tstamp formatted as "ddmmyy hhmm" (According to $TYPO3_CONF_VARS['SYS']['ddmmyy'] AND $TYPO3_CONF_VARS['SYS']['hhmm'])
+ * Usage: 28
+ *
+ * @param integer Time stamp, seconds
+ * @return string Formatted time
+ */
+ public static function datetime($value) {
+ return date($GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'].' '.$GLOBALS['TYPO3_CONF_VARS']['SYS']['hhmm'], $value);
+ }
+
+ /**
+ * Returns $value (in seconds) formatted as hh:mm:ss
+ * For instance $value = 3600 + 60*2 + 3 should return "01:02:03"
+ * Usage: 1 (class t3lib_BEfunc)
+ *
+ * @param integer Time stamp, seconds
+ * @param boolean Output hh:mm:ss. If false: hh:mm
+ * @return string Formatted time
+ */
+ public static function time($value, $withSeconds = TRUE) {
+ $hh = floor($value/3600);
+ $min = floor(($value-$hh*3600)/60);
+ $sec = $value-$hh*3600-$min*60;
+ $l = sprintf('%02d', $hh).':'.sprintf('%02d', $min);
+ if ($withSeconds) {
+ $l .= ':'.sprintf('%02d', $sec);
+ }
+ return $l;
+ }
+
+ /**
+ * Returns the "age" in minutes / hours / days / years of the number of $seconds inputted.
+ * Usage: 15
+ *
+ * @param integer $seconds could be the difference of a certain timestamp and time()
+ * @param string $labels should be something like ' min| hrs| days| yrs'. This value is typically delivered by this function call: $GLOBALS["LANG"]->sL("LLL:EXT:lang/locallang_core.php:labels.minutesHoursDaysYears")
+ * @return string Formatted time
+ */
+ public static function calcAge($seconds, $labels = 'min|hrs|days|yrs') {
+ $labelArr = explode('|', $labels);
+ $prefix = '';
+ if ($seconds<0) {$prefix = '-'; $seconds = abs($seconds);}
+ if ($seconds<3600) {
+ $seconds = round ($seconds/60).' '.trim($labelArr[0]);
+ } elseif ($seconds<24*3600) {
+ $seconds = round ($seconds/3600).' '.trim($labelArr[1]);
+ } elseif ($seconds<365*24*3600) {
+ $seconds = round ($seconds/(24*3600)).' '.trim($labelArr[2]);
+ } else {
+ $seconds = round ($seconds/(365*24*3600)).' '.trim($labelArr[3]);
+ }
+ return $prefix.$seconds;
+ }
+
+ /**
+ * Returns a formatted timestamp if $tstamp is set.
+ * The date/datetime will be followed by the age in parenthesis.
+ * Usage: 3
+ *
+ * @param integer Time stamp, seconds
+ * @param integer 1/-1 depending on polarity of age.
+ * @param string $date=="date" will yield "dd:mm:yy" formatting, otherwise "dd:mm:yy hh:mm"
+ * @return string
+ */
+ public static function dateTimeAge($tstamp, $prefix = 1, $date = '') {
+ return $tstamp ?
+ ($date=='date' ? self::date($tstamp) : self::datetime($tstamp)) .
+ ' (' . self::calcAge($prefix * ($GLOBALS['EXEC_TIME'] - $tstamp), $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.minutesHoursDaysYears')) . ')'
+ : '';
+ }
+}
+?>
\ No newline at end of file
Eigenschaftsänderungen: t3lib\utility\class.t3lib_utility_date.php
___________________________________________________________________
Hinzugefügt: svn:keywords
+ Date Author Revision Id HeadURL
Hinzugefügt: svn:eol-style
+ native
Index: typo3/alt_doc.php
===================================================================
--- typo3/alt_doc.php (Revision 8042)
+++ typo3/alt_doc.php (Arbeitskopie)
@@ -883,7 +883,7 @@
if ($undoButtonR = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($undoRes)) {
$aOnClick = 'window.location.href=\'show_rechis.php?element='.rawurlencode($this->firstEl['table'].':'.$this->firstEl['uid']).'&revert=ALL_FIELDS&sumUp=-1&returnUrl='.rawurlencode($this->R_URI).'\'; return false;';
$buttons['undo'] = '' .
+ ' title="' . htmlspecialchars(sprintf($LANG->getLL('undoLastChange'), t3lib_utility_Date::calcAge($GLOBALS['EXEC_TIME'] - $undoButtonR['tstamp'], $LANG->sL('LLL:EXT:lang/locallang_core.php:labels.minutesHoursDaysYears')))) . '">' .
t3lib_iconWorks::getSpriteIcon('actions-edit-undo') .
'';
}
Index: typo3/logomenu.php
===================================================================
--- typo3/logomenu.php (Revision 8042)
+++ typo3/logomenu.php (Arbeitskopie)
@@ -160,7 +160,7 @@
$elRow = t3lib_BEfunc::getRecord($row['tablename'],$row['recuid']);
if (is_array($elRow)) {
$items[] = array(
- 'title' => t3lib_div::fixed_lgd_cs(t3lib_BEfunc::getRecordTitle($row['tablename'], $elRow), $GLOBALS['BE_USER']->uc['titleLen']) . ' - ' . t3lib_BEfunc::calcAge($GLOBALS['EXEC_TIME'] - $row['tstamp_MAX']),
+ 'title' => t3lib_div::fixed_lgd_cs(t3lib_BEfunc::getRecordTitle($row['tablename'], $elRow), $GLOBALS['BE_USER']->uc['titleLen']) . ' - ' . t3lib_utility_Date::calcAge($GLOBALS['EXEC_TIME'] - $row['tstamp_MAX']),
'icon' => array(t3lib_iconworks::getIcon($row['tablename'],$elRow),'width="18" height="16"'),
'onclick' => 'content.'.t3lib_BEfunc::editOnClick('&edit['.$row['tablename'].']['.$row['recuid'].']=edit','','dummy.php')
);
Index: typo3/mod/user/ws/class.wslib_gui.php
===================================================================
--- typo3/mod/user/ws/class.wslib_gui.php (Revision 8042)
+++ typo3/mod/user/ws/class.wslib_gui.php (Arbeitskopie)
@@ -844,7 +844,7 @@
$text = $LANG->getLL('stage_undefined');
break;
}
- $text = t3lib_BEfunc::datetime($dat['tstamp']).': ' . sprintf($text, htmlspecialchars($username));
+ $text = t3lib_utility_Date::datetime($dat['tstamp']).': ' . sprintf($text, htmlspecialchars($username));
$text.= ($data['comment'] ? '
' . $LANG->getLL('stage_label_user_comment') . ' ' . htmlspecialchars($data['comment']) . '' : '');
$entry[] = $text;
Index: typo3/mod/user/ws/index.php
===================================================================
--- typo3/mod/user/ws/index.php (Revision 8042)
+++ typo3/mod/user/ws/index.php (Arbeitskopie)
@@ -707,9 +707,9 @@
'' . $LANG->getLL('workspace_list_label_frozen') . ' | ' .
'' . $LANG->getLL($wksp['freeze'] ? 'workspace_list_label_frozen_yes' : 'workspace_list_label_frozen_no') . ' |
' .
'' . $LANG->getLL('workspace_list_label_publish_date') . ' | ' .
- '' . ($wksp['publish_time'] == 0 ? ' –' : t3lib_BEfunc::datetime($wksp['publish_time'])) . ' |
' .
+ '' . ($wksp['publish_time'] == 0 ? ' –' : t3lib_utility_Date::datetime($wksp['publish_time'])) . ' | ' .
'' . $LANG->getLL('workspace_list_label_unpublish_date') . ' | ' .
- '' . ($wksp['unpublish_time'] == 0 ? ' –' : t3lib_BEfunc::datetime($wksp['unpublish_time'])) . ' |
' .
+ '' . ($wksp['unpublish_time'] == 0 ? ' –' : t3lib_utility_Date::datetime($wksp['unpublish_time'])) . ' | ' .
'' . $LANG->getLL('workspace_list_label_your_access') . ' | ' .
'' . $LANG->getLL('workspace_list_access_' . $wksp['_ACCESS']) . ' |
' .
'' . $LANG->getLL('workspace_list_label_workspace_users') . ' | ' .
Index: typo3/sysext/cms/layout/class.tx_cms_layout.php
===================================================================
--- typo3/sysext/cms/layout/class.tx_cms_layout.php (Revision 8042)
+++ typo3/sysext/cms/layout/class.tx_cms_layout.php (Arbeitskopie)
@@ -1687,7 +1687,7 @@
if ($row['header_layout'] == 100) {
$hiddenHeaderNote = ' [' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:labels.hidden', true) . ']';
}
- $outHeader= ($row['date'] ? htmlspecialchars($this->itemLabels['date'].' '.t3lib_BEfunc::date($row['date'])).'
':'').
+ $outHeader= ($row['date'] ? htmlspecialchars($this->itemLabels['date'].' '.t3lib_utility_Date::date($row['date'])).'
':'').
'' . $this->linkEditContent($this->renderText($row['header']), $row) . $hiddenHeaderNote . '
';
}
@@ -2140,8 +2140,8 @@
$theData = Array();
$theData['subject'] = t3lib_div::fixed_lgd_cs(htmlspecialchars($row['subject']),25).' ';
$theData['author'] = t3lib_div::fixed_lgd_cs(htmlspecialchars($row['author']),15).' ';
- $theData['date'] = t3lib_div::fixed_lgd_cs(t3lib_BEfunc::datetime($row['crdate']),20).' ';
- $theData['age'] = t3lib_BEfunc::calcAge($GLOBALS['EXEC_TIME'] - $row['crdate'], $this->agePrefixes) . ' ';
+ $theData['date'] = t3lib_div::fixed_lgd_cs(t3lib_utility_Date::datetime($row['crdate']),20).' ';
+ $theData['age'] = t3lib_utility_Date::calcAge($GLOBALS['EXEC_TIME'] - $row['crdate'], $this->agePrefixes) . ' ';
if ($re) {
$theData['replys'] = $re;
}
@@ -2439,20 +2439,20 @@
// Created:
$lines[] = array(
$LANG->getLL('pI_crDate') . ':',
- t3lib_BEfunc::datetime($rec['crdate']) . ' (' . t3lib_BEfunc::calcAge($GLOBALS['EXEC_TIME'] - $rec['crdate'], $this->agePrefixes) . ')',
+ t3lib_utility_Date::datetime($rec['crdate']) . ' (' . t3lib_utility_Date::calcAge($GLOBALS['EXEC_TIME'] - $rec['crdate'], $this->agePrefixes) . ')',
);
// Last change:
$lines[] = array(
$LANG->getLL('pI_lastChange') . ':',
- t3lib_BEfunc::datetime($rec['tstamp']) . ' (' . t3lib_BEfunc::calcAge($GLOBALS['EXEC_TIME'] - $rec['tstamp'],$this->agePrefixes) . ')',
+ t3lib_utility_Date::datetime($rec['tstamp']) . ' (' . t3lib_utility_Date::calcAge($GLOBALS['EXEC_TIME'] - $rec['tstamp'],$this->agePrefixes) . ')',
);
// Last change of content:
if ($rec['SYS_LASTCHANGED']) {
$lines[] = array(
$LANG->getLL('pI_lastChangeContent') . ':',
- t3lib_BEfunc::datetime($rec['SYS_LASTCHANGED']) . ' (' . t3lib_BEfunc::calcAge($GLOBALS['EXEC_TIME'] - $rec['SYS_LASTCHANGED'], $this->agePrefixes) . ')',
+ t3lib_utility_Date::datetime($rec['SYS_LASTCHANGED']) . ' (' . t3lib_utility_Date::calcAge($GLOBALS['EXEC_TIME'] - $rec['SYS_LASTCHANGED'], $this->agePrefixes) . ')',
);
}
@@ -2479,7 +2479,7 @@
$rrow2 = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
$lines[]='';
- $lines[]=array($LANG->getLL('pI_hitsPeriod').':',t3lib_BEfunc::date($rrow2[0]).' - '.t3lib_BEfunc::date($rrow2[1]).' ('.t3lib_BEfunc::calcAge($rrow2[1]-$rrow2[0],$this->agePrefixes).')');
+ $lines[]=array($LANG->getLL('pI_hitsPeriod').':',t3lib_utility_Date::date($rrow2[0]).' - '.t3lib_utility_Date::date($rrow2[1]).' ('.t3lib_utility_Date::calcAge($rrow2[1]-$rrow2[0],$this->agePrefixes).')');
$lines[]=array($LANG->getLL('pI_hitsTotal').':',$rrow[0]);
Index: typo3/sysext/cms/layout/db_layout.php
===================================================================
--- typo3/sysext/cms/layout/db_layout.php (Revision 8042)
+++ typo3/sysext/cms/layout/db_layout.php (Arbeitskopie)
@@ -1268,7 +1268,7 @@
// Undo button
$buttons['undo'] = '' .
+ title="' . htmlspecialchars(sprintf($LANG->getLL('undoLastChange'), t3lib_utility_Date::calcAge($GLOBALS['EXEC_TIME'] - $this->undoButtonR['tstamp'], $LANG->sL('LLL:EXT:lang/locallang_core.php:labels.minutesHoursDaysYears')))) . '">' .
t3lib_iconWorks::getSpriteIcon('actions-edit-undo') .
'';
Index: typo3/sysext/cms/web_info/class.tx_cms_webinfo.php
===================================================================
--- typo3/sysext/cms/web_info/class.tx_cms_webinfo.php (Revision 8042)
+++ typo3/sysext/cms/web_info/class.tx_cms_webinfo.php (Arbeitskopie)
@@ -126,7 +126,7 @@
}
$timespan_b = mktime (0,0,0);
$timespan_e = mktime (0,0,0)-(30-1)*3600*24+1;
- $header='
'.sprintf($LANG->getLL('stat_period'),t3lib_BEfunc::date($timespan_b),t3lib_BEfunc::date($timespan_e)).'
';
+ $header='
'.sprintf($LANG->getLL('stat_period'),t3lib_utility_Date::date($timespan_b),t3lib_utility_Date::date($timespan_e)).'
';
//
$dblist->start($this->pObj->id,'pages',0);
Index: typo3/sysext/dbal/mod1/index.php
===================================================================
--- typo3/sysext/dbal/mod1/index.php (Revision 8042)
+++ typo3/sysext/dbal/mod1/index.php (Arbeitskopie)
@@ -507,7 +507,7 @@
while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
$tRows[] = '
- ' . t3lib_BEfunc::datetime($row['tstamp']) . ' |
+ ' . t3lib_utility_Date::datetime($row['tstamp']) . ' |
' . htmlspecialchars($row['script']) . ' |
' . htmlspecialchars($row['tablename']) . ' |
' . str_replace(array('\'\'', '""', 'IS NULL', 'IS NOT NULL'), array('\'\'', '""', 'IS NULL', 'IS NOT NULL'), htmlspecialchars($row['whereclause'])) . ' |
@@ -558,7 +558,7 @@
while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
$tRows[] = '
- ' . t3lib_BEfunc::datetime($row['tstamp']) . ' |
+ ' . t3lib_utility_Date::datetime($row['tstamp']) . ' |
' . htmlspecialchars($row['qrycount']) . ' |
' . ($row['error'] ? 'ERR' : '') . ' |
' . htmlspecialchars($row['calc_sum']) . ' |
Index: typo3/sysext/indexed_search/mod/index.php
===================================================================
--- typo3/sysext/indexed_search/mod/index.php (Revision 8042)
+++ typo3/sysext/indexed_search/mod/index.php (Arbeitskopie)
@@ -323,9 +323,9 @@
htmlentities(t3lib_div::fixed_lgd_cs($row["item_title"],30)),
t3lib_div::formatSize($row["item_size"]),
$this->getNumberOfWords($row["phash"]),
- t3lib_BEfunc::datetime($row["item_mtime"]),
- t3lib_BEfunc::datetime($row["crdate"]),
- ($row["tstamp"]!=$row["crdate"] ? t3lib_BEfunc::datetime($row["tstamp"]) : ""),
+ t3lib_utility_Date::datetime($row["item_mtime"]),
+ t3lib_utility_Date::datetime($row["crdate"]),
+ ($row["tstamp"]!=$row["crdate"] ? t3lib_utility_Date::datetime($row["tstamp"]) : ""),
$row["parsetime"],
$this->getNumberOfSections($row["phash"])."/".$grListRec[0]["pcount"]."/".$this->getNumberOfFulltext($row["phash"]),
$row["pcount"]."/".$this->formatFeGroup($grListRec),
@@ -343,9 +343,9 @@
"",
t3lib_div::formatSize($row2["item_size"]),
$this->getNumberOfWords($row2["phash"]),
- t3lib_BEfunc::datetime($row2["item_mtime"]),
- t3lib_BEfunc::datetime($row2["crdate"]),
- ($row2["tstamp"]!=$row2["crdate"] ? t3lib_BEfunc::datetime($row2["tstamp"]) : ""),
+ t3lib_utility_Date::datetime($row2["item_mtime"]),
+ t3lib_utility_Date::datetime($row2["crdate"]),
+ ($row2["tstamp"]!=$row2["crdate"] ? t3lib_utility_Date::datetime($row2["tstamp"]) : ""),
$row2["parsetime"],
$this->getNumberOfSections($row2["phash"])."/".$grListRec[0]["pcount"]."/".$this->getNumberOfFulltext($row2["phash"]),
"-/".$this->formatFeGroup($grListRec),
@@ -390,9 +390,9 @@
htmlentities(t3lib_div::fixed_lgd_cs($row["item_title"],30)),
t3lib_div::formatSize($row["item_size"]),
$this->getNumberOfWords($row["phash"]),
- t3lib_BEfunc::datetime($row["item_mtime"]),
- t3lib_BEfunc::datetime($row["crdate"]),
- ($row["tstamp"]!=$row["crdate"] ? t3lib_BEfunc::datetime($row["tstamp"]) : ""),
+ t3lib_utility_Date::datetime($row["item_mtime"]),
+ t3lib_utility_Date::datetime($row["crdate"]),
+ ($row["tstamp"]!=$row["crdate"] ? t3lib_utility_Date::datetime($row["tstamp"]) : ""),
$row["parsetime"],
$this->getNumberOfSections($row["phash"])."/".$grListRec[0]["pcount"]."/".$this->getNumberOfFulltext($row["phash"]),
$row["pcount"],
@@ -411,8 +411,8 @@
"",
$this->getNumberOfWords($row2["phash"]),
"",
- t3lib_BEfunc::datetime($row2["crdate"]),
- ($row2["tstamp"]!=$row2["crdate"] ? t3lib_BEfunc::datetime($row2["tstamp"]) : ""),
+ t3lib_utility_Date::datetime($row2["crdate"]),
+ ($row2["tstamp"]!=$row2["crdate"] ? t3lib_utility_Date::datetime($row2["tstamp"]) : ""),
$row2["parsetime"],
$this->getNumberOfSections($row2["phash"])."/".$grListRec[0]["pcount"]."/".$this->getNumberOfFulltext($row2["phash"]),
"",
Index: typo3/sysext/indexed_search/modfunc1/class.tx_indexedsearch_modfunc1.php
===================================================================
--- typo3/sysext/indexed_search/modfunc1/class.tx_indexedsearch_modfunc1.php (Revision 8042)
+++ typo3/sysext/indexed_search/modfunc1/class.tx_indexedsearch_modfunc1.php (Arbeitskopie)
@@ -515,7 +515,7 @@
$lines[] = ''.htmlspecialchars($this->utf8_to_currentCharset($row['item_description'])).'... | ';
$lines[] = ''.t3lib_div::formatSize($row['item_size']).' | ';
- $lines[] = ''.t3lib_BEfunc::dateTimeAge($row['tstamp']).' | ';
+ $lines[] = ''.t3lib_utility_Date::dateTimeAge($row['tstamp']).' | ';
break;
}
Index: typo3/sysext/lowlevel/clmods/class.syslog.php
===================================================================
--- typo3/sysext/lowlevel/clmods/class.syslog.php (Revision 8042)
+++ typo3/sysext/lowlevel/clmods/class.syslog.php (Arbeitskopie)
@@ -98,7 +98,7 @@
);
foreach($rows as $r) {
$l = unserialize($r['log_data']);
- $explained = '#'.$r['uid'].' '.t3lib_BEfunc::datetime($r['tstamp']).' USER['.$r['userid'].']: '.sprintf($r['details'],$l[0],$l[1],$l[2],$l[3],$l[4],$l[5]);
+ $explained = '#'.$r['uid'].' '.t3lib_utility_Date::datetime($r['tstamp']).' USER['.$r['userid'].']: '.sprintf($r['details'],$l[0],$l[1],$l[2],$l[3],$l[4],$l[5]);
$resultArray['listing'][$r['uid']] = $explained;
$resultArray['allDetails'][$r['uid']] = array($explained,t3lib_div::arrayToLogString($r,'uid,userid,action,recuid,tablename,recpid,error,tstamp,type,details_nr,IP,event_pid,NEWid,workspace'));
}
Index: typo3/sysext/sys_action/task/class.tx_sysaction_task.php
===================================================================
--- typo3/sysext/sys_action/task/class.tx_sysaction_task.php (Revision 8042)
+++ typo3/sysext/sys_action/task/class.tx_sysaction_task.php (Arbeitskopie)
@@ -765,7 +765,7 @@
$title = t3lib_BEfunc::getRecordTitle($el['table'], $dbAnalysis->results[$el['table']][$el['id']]);
$description = $GLOBALS['LANG']->sL($GLOBALS['TCA'][$el['table']]['ctrl']['title'], 1);
if (isset($record['crdate'])) { // @todo: which information could be needfull
- $description .= ' - ' . t3lib_BEfunc::dateTimeAge($record['crdate']);
+ $description .= ' - ' . t3lib_utility_Date::dateTimeAge($record['crdate']);
}
$actionList[$el['id']] = array(
Index: typo3/wizard_rte.php
===================================================================
--- typo3/wizard_rte.php (Revision 8042)
+++ typo3/wizard_rte.php (Arbeitskopie)
@@ -282,7 +282,7 @@
// Undo/Revert:
if ($undoButton) {
$buttons['undo'] = '' .
- 'doc->backPath, 'gfx/undo.gif') . ' class="c-inputButton" title="' . htmlspecialchars(sprintf($GLOBALS['LANG']->getLL('rte_undoLastChange'), t3lib_BEfunc::calcAge($GLOBALS['EXEC_TIME'] - $undoButtonR['tstamp'], $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.minutesHoursDaysYears')))) . '" alt="" />' .
+ 'doc->backPath, 'gfx/undo.gif') . ' class="c-inputButton" title="' . htmlspecialchars(sprintf($GLOBALS['LANG']->getLL('rte_undoLastChange'), t3lib_utility_Date::calcAge($GLOBALS['EXEC_TIME'] - $undoButtonR['tstamp'], $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.minutesHoursDaysYears')))) . '" alt="" />' .
'';
}