Changeset View
Standalone View
core/units/helpers/date_helper.php
- This file was added.
Property | Old Value | New Value |
---|---|---|
svn:eol-style | null | LF \ No newline at end of property |
svn:keywords | null | Id \ No newline at end of property |
<?php | |||||
/** | |||||
Lint: CodingStandard.Commenting.DocComment.MissingShort: Missing short description in doc comment | |||||
Not Done Reply
alex: # missing licensing file comment
# missing `svn:eol` and `svn:keywords` properties (see how… | |||||
* @version $Id$ | |||||
Expected 1 space(s) before asterisk; 0 found Lint: Squiz.Commenting.DocCommentAlignment.SpaceBeforeStar: Expected 1 space(s) before asterisk; 0 found | |||||
Tag value for @version tag indented incorrectly; expected 3 spaces but found 2 Lint: CodingStandard.Commenting.DocComment.TagValueIndent: Tag value for @version tag indented incorrectly; expected 3 spaces but found 2 | |||||
* @package In-Portal | |||||
Tag value for @package tag indented incorrectly; expected 3 spaces but found 2 Lint: CodingStandard.Commenting.DocComment.TagValueIndent: Tag value for @package tag indented incorrectly; expected 3 spaces but found 2 | |||||
Expected 1 space(s) before asterisk; 0 found Lint: Squiz.Commenting.DocCommentAlignment.SpaceBeforeStar: Expected 1 space(s) before asterisk; 0 found | |||||
* @copyright Copyright (C) 1997 - 2016 Intechnic. All rights reserved. | |||||
Tag value for @copyright tag indented incorrectly; expected 1 spaces but found 4 Lint: CodingStandard.Commenting.DocComment.TagValueIndent: Tag value for @copyright tag indented incorrectly; expected 1 spaces but found 4 | |||||
Expected 1 space(s) before asterisk; 0 found Lint: Squiz.Commenting.DocCommentAlignment.SpaceBeforeStar: Expected 1 space(s) before asterisk; 0 found | |||||
* @license GNU/GPL | |||||
Tag value for @license tag indented incorrectly; expected 3 spaces but found 6 Lint: CodingStandard.Commenting.DocComment.TagValueIndent: Tag value for @license tag indented incorrectly; expected 3 spaces but found 6 | |||||
Expected 1 space(s) before asterisk; 0 found Lint: Squiz.Commenting.DocCommentAlignment.SpaceBeforeStar: Expected 1 space(s) before asterisk; 0 found | |||||
* In-Portal is Open Source software. | |||||
Expected 1 space(s) before asterisk; 0 found Lint: Squiz.Commenting.DocCommentAlignment.SpaceBeforeStar: Expected 1 space(s) before asterisk; 0 found | |||||
* This means that this software may have been modified pursuant | |||||
Expected 1 space(s) before asterisk; 0 found Lint: Squiz.Commenting.DocCommentAlignment.SpaceBeforeStar: Expected 1 space(s) before asterisk; 0 found | |||||
Not Done ReplyPlease change to: Returns human representation of given seconds (e.g. `12 days, and 5 hours`). alex: Please change to:
```
Returns human representation of given seconds (e.g. `12 days, and 5… | |||||
* the GNU General Public License, and as distributed it includes | |||||
Expected 1 space(s) before asterisk; 0 found Lint: Squiz.Commenting.DocCommentAlignment.SpaceBeforeStar: Expected 1 space(s) before asterisk; 0 found | |||||
* or is derivative of works licensed under the GNU General Public License | |||||
Expected 1 space(s) before asterisk; 0 found Lint: Squiz.Commenting.DocCommentAlignment.SpaceBeforeStar: Expected 1 space(s) before asterisk; 0 found | |||||
Not Done ReplyPlease change to Date/time interval in seconds. to Seconds. alex: Please change to `Date/time interval in seconds.` to `Seconds`. | |||||
* or other free or open source software licenses. | |||||
Expected 1 space(s) before asterisk; 0 found Lint: Squiz.Commenting.DocCommentAlignment.SpaceBeforeStar: Expected 1 space(s) before asterisk; 0 found | |||||
* See http://www.in-portal.org/license for copyright notices and details. | |||||
Expected 1 space(s) before asterisk; 0 found Lint: Squiz.Commenting.DocCommentAlignment.SpaceBeforeStar: Expected 1 space(s) before asterisk; 0 found | |||||
*/ | |||||
Expected 1 space(s) before asterisk; 0 found Lint: Squiz.Commenting.DocCommentAlignment.SpaceBeforeStar: Expected 1 space(s) before asterisk; 0 found | |||||
Not Done Reply
alex: # the formatting of File Comment should be broken (as with any other licensing comment in the… | |||||
defined('FULL_PATH') or die('restricted access!'); | |||||
class DateHelper extends kHelper | |||||
{ | |||||
/** | |||||
* Returns human representation of given seconds (e.g. `12 days, and 5 hours`). | |||||
* | |||||
* @param integer $seconds Seconds. | |||||
* @param integer $detalization_level Detalization level. | |||||
* | |||||
* @return string | |||||
*/ | |||||
public function getHumanTime($seconds, $detalization_level) | |||||
{ | |||||
$units = array( | |||||
'year' => 29030400, // Seconds in a year (12 months). | |||||
'month' => 2419200, // Seconds in a month (4 weeks). | |||||
'week' => 604800, // Seconds in a week (7 days). | |||||
'day' => 86400, // Seconds in a day (24 hours). | |||||
'hour' => 3600, // Seconds in an hour (60 minutes). | |||||
'minute' => 60, // Seconds in a minute (60 seconds). | |||||
'second' => 1, // 1 second. | |||||
); | |||||
$res = ''; | |||||
$current_detalization_level = 0; | |||||
foreach ( $units as $unit => $multiplier ) { | |||||
if ( $seconds >= $multiplier ) { | |||||
$and = (!$res || $multiplier != 1) ? '' : 'and '; | |||||
$res .= ', ' . $and . intval($seconds / $multiplier); | |||||
$res .= ' ' . $unit . (intval($seconds / $multiplier) == 1 ? '' : 's'); | |||||
$seconds -= intval($seconds / $multiplier) * $multiplier; | |||||
$current_detalization_level++; | |||||
if ( $current_detalization_level >= $detalization_level ) { | |||||
break; | |||||
} | |||||
} | |||||
} | |||||
return substr($res, strlen(', ')); | |||||
} | |||||
/** | |||||
* Returns human representation of given seconds in short format (e.g. `12d 5h`). | |||||
* | |||||
* @param integer $seconds Seconds. | |||||
* | |||||
* @return string | |||||
*/ | |||||
public function getShortHumanTime($seconds) | |||||
{ | |||||
// Using "DateInterval" class directly will lose 61+ second. | |||||
$now = new DateTime(); | |||||
Not Done ReplyPlease add following comment above this line: // Using "DateInterval" class directly will lose 61+ second. alex: Please add following comment above this line:
```
lang=php
// Using "DateInterval" class… | |||||
$futher_date = new DateTime(); | |||||
Not Done ReplyPlease rename $diff_date into $futher_date. Variable name must represent content inside that variable, not the usage of that variable in the code. alex: Please rename `$diff_date` into `$futher_date`.
---
Variable name must represent content… | |||||
$now->setTimestamp(0); | |||||
Not Done ReplyMy apologies, but $futher_date turned out to be grammatically incorrect word. Please rename it into $further_date now. alex: My apologies, but `$futher_date` turned out to be grammatically incorrect word. Please rename… | |||||
$futher_date->setTimestamp($seconds); | |||||
Not Done ReplyPlease replace with following (it's shorter and hopefully works the same): $now->setTimestamp(0); $diff_date->setTimestamp($seconds); alex: Please replace with following (it's shorter and hopefully works the same):
```
lang=php
$now… | |||||
$interval = $futher_date->diff($now); | |||||
$ret = $interval->format(' %yy %mm %dd %hh %imi %ss'); | |||||
Not Done ReplyPlease inline this into return statement below. alex: Please inline this into `return` statement below. | |||||
return trim(preg_replace('/ 0\w+/', '', $ret)); | |||||
} | |||||
} |
Missing short description in doc comment