Exemple #1
0
 function testFormatDateWithTZFromSession()
 {
     date_default_timezone_set("UTC");
     \OC::$server->getSession()->set('timezone', 3);
     $result = OC_Util::formatDate(1350129205, false);
     $expected = 'October 13, 2012 at 2:53:25 PM GMT+0';
     $this->assertEquals($expected, $result);
 }
Exemple #2
0
 function testFormatDate()
 {
     $result = OC_Util::formatDate(1350129205);
     $expected = 'October 13, 2012 11:53';
     $this->assertEquals($expected, $result);
     $result = OC_Util::formatDate(1102831200, true);
     $expected = 'December 12, 2004';
     $this->assertEquals($expected, $result);
 }
Exemple #3
0
 function testFormatDateWithTZFromSession()
 {
     date_default_timezone_set("UTC");
     $oldDateTimeFormatter = \OC::$server->query('DateTimeFormatter');
     \OC::$server->getSession()->set('timezone', 3);
     $newDateTimeFormatter = new \OC\DateTimeFormatter(\OC::$server->getDateTimeZone()->getTimeZone(), new \OC_L10N('lib', 'en'));
     $this->setDateFormatter($newDateTimeFormatter);
     $result = OC_Util::formatDate(1350129205, false);
     $expected = 'October 13, 2012 at 2:53:25 PM GMT+3';
     $this->assertEquals($expected, $result);
     $this->setDateFormatter($oldDateTimeFormatter);
 }
Exemple #4
0
 /**
  * @dataProvider formatDateWithTZFromSessionData
  */
 function testFormatDateWithTZFromSession($offset, $expected, $expectedTimeZone)
 {
     date_default_timezone_set("UTC");
     $oldDateTimeFormatter = \OC::$server->query('DateTimeFormatter');
     \OC::$server->getSession()->set('timezone', $offset);
     $selectedTimeZone = \OC::$server->getDateTimeZone()->getTimeZone(1350129205);
     $this->assertEquals($expectedTimeZone, $selectedTimeZone->getName());
     $newDateTimeFormatter = new \OC\DateTimeFormatter($selectedTimeZone, new \OC_L10N('lib', 'en'));
     $this->setDateFormatter($newDateTimeFormatter);
     $result = OC_Util::formatDate(1350129205, false);
     $this->assertEquals($expected, $result);
     $this->setDateFormatter($oldDateTimeFormatter);
 }
Exemple #5
0
 /**
  * formats a timestamp in the "right" way
  * @param int $timestamp $timestamp
  * @param bool $dateOnly option to omit time from the result
  * @param DateTimeZone|string $timeZone where the given timestamp shall be converted to
  * @return string timestamp
  *
  * @deprecated 8.0.0 Use \OC::$server->query('DateTimeFormatter') instead
  * @since 4.0.0
  */
 public static function formatDate($timestamp, $dateOnly = false, $timeZone = null)
 {
     return \OC_Util::formatDate($timestamp, $dateOnly, $timeZone);
 }
Exemple #6
0
        ?>
			</td>
			<td>
				<?php 
        p($entry->app);
        ?>
			</td>
			<td class="log-message">
				<?php 
        p($entry->message);
        ?>
			</td>
			<td class="date">
				<?php 
        if (is_int($entry->time)) {
            p(OC_Util::formatDate($entry->time));
        } else {
            p($entry->time);
        }
        ?>
			</td>
		</tr>
		<?php 
    }
    ?>
	</table>
	<?php 
    if ($_['logFileSize'] > 0) {
        ?>
	<a href="<?php 
        print_unescaped(OC::$server->getURLGenerator()->linkToRoute('settings.LogSettings.download'));
Exemple #7
0
 /**
  * @brief formats a timestamp in the "right" way
  * @param int $timestamp $timestamp
  * @param bool $dateOnly option to omit time from the result
  */
 public static function formatDate($timestamp, $dateOnly = false)
 {
     return \OC_Util::formatDate($timestamp, $dateOnly);
 }
OC_Util::addScript("files", "files");
OC_Util::addScript('files', 'filelist');
OC_Util::addScript('files', 'fileactions');
if (!isset($_SESSION['timezone'])) {
    OC_Util::addScript('files', 'timezone');
}
OC_App::setActiveNavigationEntry("files_index");
// Load the files
$dir = isset($_GET['dir']) ? stripslashes($_GET['dir']) : '';
// Redirect if directory does not exist
if (!OC_Filesystem::is_dir($dir . '/')) {
    header("Location: " . $_SERVER['PHP_SELF'] . "");
}
$files = array();
foreach (OC_Files::getdirectorycontent($dir) as $i) {
    $i["date"] = OC_Util::formatDate($i["mtime"]);
    if ($i['type'] == 'file') {
        $fileinfo = pathinfo($i['name']);
        $i['basename'] = $fileinfo['filename'];
        if (!empty($fileinfo['extension'])) {
            $i['extention'] = '.' . $fileinfo['extension'];
        } else {
            $i['extention'] = '';
        }
    }
    if ($i['directory'] == '/') {
        $i['directory'] = '';
    }
    $files[] = $i;
}
// Make breadcrumb
Exemple #9
0
    ?>
						...
					</option>
				</select>
			</td>
			<td class="storageLocation"><?php 
    p($user["storageLocation"]);
    ?>
</td>
			<?php 
    if ($user["lastLogin"] === 0) {
        $lastLogin = $l->t('never');
        $lastLoginDate = $lastLogin;
    } else {
        $lastLogin = relative_modified_date($user["lastLogin"]);
        $lastLoginDate = \OC_Util::formatDate($user["lastLogin"]);
    }
    ?>
			<td class="lastLogin" title="<?php 
    p('<span class="usersLastLoginTooltip">' . $lastLoginDate . '</span>');
    ?>
"><?php 
    p($lastLogin);
    ?>
</td>
			<td class="remove">
				<?php 
    if ($user['name'] != OC_User::getUser()) {
        ?>
					<a href="#" class="action delete" original-title="<?php 
        p($l->t('Delete'));
 $source = substr($source, strlen("/" . $user . "/files"));
 $subPath = isset($_GET['path']) ? $_GET['path'] : '';
 $root = $source;
 $source .= $subPath;
 if (!OC_Filesystem::file_exists($source)) {
     header("HTTP/1.0 404 Not Found");
     $tmpl = new OC_Template("", "404", "guest");
     $tmpl->assign("file", $subPath);
     $tmpl->printPage();
     exit;
 }
 if (OC_Filesystem::is_dir($source)) {
     $files = array();
     $rootLength = strlen($root);
     foreach (OC_Files::getdirectorycontent($source) as $i) {
         $i['date'] = OC_Util::formatDate($i['mtime']);
         if ($i['type'] == 'file') {
             $fileinfo = pathinfo($i['name']);
             $i['basename'] = $fileinfo['filename'];
             $i['extention'] = isset($fileinfo['extension']) ? '.' . $fileinfo['extension'] : '';
         }
         $i['directory'] = substr($i['directory'], $rootLength);
         if ($i['directory'] == "/") {
             $i['directory'] = "";
         }
         $files[] = $i;
     }
     // Make breadcrumb
     $breadcrumb = array();
     $pathtohere = "";
     foreach (explode("/", $subPath) as $i) {
			<td>
				<?php 
    echo $levels[$entry->level];
    ?>
			</td>
			<td>
				<?php 
    echo $entry->app;
    ?>
			</td>
			<td>
				<?php 
    echo htmlentities($entry->message);
    ?>
			</td>
			<td>
				<?php 
    echo OC_Util::formatDate($entry->time);
    ?>
			</td>
		</tr>
	<?php 
}
?>
</table>
<input id='moreLog' type='button' value='<?php 
echo $l->t('More');
?>
...'></input>
</fieldset>