Skip to content

Commit

Permalink
Add Seconds_per_day constant
Browse files Browse the repository at this point in the history
  • Loading branch information
mantis committed May 17, 2009
1 parent 756deda commit fcf225e
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 14 deletions.
4 changes: 2 additions & 2 deletions core/bugnote_api.php
Expand Up @@ -577,7 +577,7 @@ function bugnote_format_id( $p_bugnote_id ) {
*/
function bugnote_stats_get_events_array( $p_bug_id, $p_from, $p_to ) {
$c_bug_id = db_prepare_int( $p_bug_id );
$c_to = strtotime( $p_to, 86399); // @23:59:59
$c_to = strtotime( $p_to, SECONDS_PER_DAY - 1 ); // @23:59:59
$c_from = strtotime( $p_from );

$t_user_table = db_get_table( 'mantis_user_table' );
Expand Down Expand Up @@ -625,7 +625,7 @@ function bugnote_stats_get_events_array( $p_bug_id, $p_from, $p_to ) {
function bugnote_stats_get_project_array( $p_project_id, $p_from, $p_to, $p_cost ) {
$c_project_id = db_prepare_int( $p_project_id );

$c_to = strtotime( $p_to, 86399); // @23:59:59
$c_to = strtotime( $p_to, SECONDS_PER_DAY - 1); // @23:59:59
$c_from = strtotime( $p_from );

if ( $c_to === false || $c_form === false ) {
Expand Down
2 changes: 2 additions & 0 deletions core/constant_inc.php
Expand Up @@ -488,3 +488,5 @@
define( 'USERLEN', 32);
define( 'REALLEN', 64);
define( 'PASSLEN', 32);

define( 'SECONDS_PER_DAY', 86400 );
6 changes: 3 additions & 3 deletions core/graph_api.php
Expand Up @@ -616,7 +616,7 @@ function create_cumulative_bydate() {

# rationalise the timestamp to a day to reduce the amount of data
$t_date = $row['date_submitted'];
$t_date = (int)( $t_date / 86400 );
$t_date = (int)( $t_date / SECONDS_PER_DAY );

if( isset( $metrics[$t_date] ) ) {
$metrics[$t_date][0]++;
Expand Down Expand Up @@ -659,7 +659,7 @@ function create_cumulative_bydate() {
if( 0 <> $t_last_id ) {

# rationalise the timestamp to a day to reduce the amount of data
$t_date_index = (int)( $t_last_date / 86400 );
$t_date_index = (int)( $t_last_date / SECONDS_PER_DAY );

if( isset( $metrics[$t_date_index] ) ) {
$metrics[$t_date_index][1]++;
Expand All @@ -682,7 +682,7 @@ function create_cumulative_bydate() {
$t_last_opened = 0;
$t_last_resolved = 0;
foreach( $metrics as $i => $vals ) {
$t_date = $i * 86400;
$t_date = $i * SECONDS_PER_DAY;
$t_metrics[$t_date][0] = $t_last_opened = $metrics[$i][0] + $t_last_opened;
$t_metrics[$t_date][1] = $t_last_resolved = $metrics[$i][1] + $t_last_resolved;
$t_metrics[$t_date][2] = $t_metrics[$t_date][0] - $t_metrics[$t_date][1];
Expand Down
2 changes: 1 addition & 1 deletion core/news_api.php
Expand Up @@ -257,7 +257,7 @@ function news_get_limited_rows( $p_offset, $p_project_id = null ) {

$t_news_table = db_get_table( 'mantis_news_table' );
$t_news_view_limit = config_get( 'news_view_limit' );
$t_news_view_limit_days = config_get( 'news_view_limit_days' ) * 86400;
$t_news_view_limit_days = config_get( 'news_view_limit_days' ) * SECONDS_PER_DAY;

switch( config_get( 'news_limit_method' ) ) {
case 0:
Expand Down
6 changes: 3 additions & 3 deletions core/summary_api.php
Expand Up @@ -191,7 +191,7 @@ function summary_print_by_enum( $p_enum_string, $p_enum ) {
function summary_new_bug_count_by_date( $p_time_length = 1 ) {
$t_mantis_bug_table = db_get_table( 'mantis_bug_table' );

$c_time_length = (int) $p_time_length * 86400;
$c_time_length = (int) $p_time_length * SECONDS_PER_DAY;

$t_project_id = helper_get_current_project();
$t_user_id = auth_get_current_user_id();
Expand All @@ -215,7 +215,7 @@ function summary_resolved_bug_count_by_date( $p_time_length = 1 ) {
$t_bug_history_table = db_get_table( 'mantis_bug_history_table' );
$t_resolved = config_get( 'bug_resolved_status_threshold' );

$c_time_length = (int) $p_time_length * 864000;
$c_time_length = (int) $p_time_length * SECONDS_PER_DAY;

$t_project_id = helper_get_current_project();
$t_user_id = auth_get_current_user_id();
Expand Down Expand Up @@ -379,7 +379,7 @@ function summary_print_by_age() {

$t_bugid = string_get_bug_view_link( $row['id'] );
$t_summary = $row['summary'];
$t_days_open = intval(( time() - strtotime( $row['date_submitted'] ) ) / 86400 );
$t_days_open = intval(( time() - strtotime( $row['date_submitted'] ) ) / SECONDS_PER_DAY );

print "<tr " . helper_alternate_class() . ">\n";
print "<td class=\"small\">$t_bugid - $t_summary</td><td class=\"right\">$t_days_open</td>\n";
Expand Down
2 changes: 1 addition & 1 deletion manage_user_page.php
Expand Up @@ -92,7 +92,7 @@

# New Accounts Form BEGIN

$days_old = 7 * 86400;
$days_old = 7 * SECONDS_PER_DAY;
$query = "SELECT *
FROM $t_user_table
WHERE ".db_helper_compare_days("" . db_now() . "","date_created","<= $days_old")."
Expand Down
2 changes: 1 addition & 1 deletion manage_user_prune.php
Expand Up @@ -34,7 +34,7 @@
$t_user_table = db_get_table( 'mantis_user_table' );

# Delete the users who have never logged in and are older than 1 week
$days_old = (int)7 * 86400;
$days_old = (int)7 * SECONDS_PER_DAY;

$query = "SELECT id
FROM $t_user_table
Expand Down
6 changes: 3 additions & 3 deletions summary_page.php
Expand Up @@ -88,9 +88,9 @@
}
$t_average_time = $t_total_time / $bug_count;

$t_largest_diff = number_format( $t_largest_diff / 86400, 2 );
$t_total_time = number_format( $t_total_time / 86400, 2 );
$t_average_time = number_format( $t_average_time / 86400, 2 );
$t_largest_diff = number_format( $t_largest_diff / SECONDS_PER_DAY, 2 );
$t_total_time = number_format( $t_total_time / SECONDS_PER_DAY, 2 );
$t_average_time = number_format( $t_average_time / SECONDS_PER_DAY, 2 );

$t_orct_arr = preg_split( '/[\)\/\(]/', lang_get( 'orct' ), -1, PREG_SPLIT_NO_EMPTY );

Expand Down

0 comments on commit fcf225e

Please sign in to comment.