Skip to content

Commit

Permalink
Now padding zeroes onto minutes and seconds
Browse files Browse the repository at this point in the history
  • Loading branch information
mschor authored and mschor committed Jan 18, 2022
1 parent a17fa90 commit 4d4c03a
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 52 deletions.
25 changes: 15 additions & 10 deletions js/dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,28 @@ function window_resized(catalog_id, chart_id) {
}, UPDATE_DELAY_SECS * 1000);
}

// TODO - copied from dcc_review.js
// TODO - copied from dcc_review.js; put into a cental location
function pad_zeroes(number) {
if (number < 10) {
return '0' + number;
}
return number;
}

function get_formatted_date(d) {
// Returns a date as a string in the following format: "2020-10-09 17:32:32 - 0400"
var month = d.getMonth() + 1;

if (month < 10) {
month = '0' + month;
}

var day = d.getDate();
var minutes = d.getMinutes();
var seconds = d.getSeconds();

if (day < 10) {
day = '0' + day;
}
month = pad_zeroes(month);
day = pad_zeroes(day);
minutes = pad_zeroes(minutes)
seconds = pad_zeroes(seconds);

var formatted = d.getFullYear() + '-' + month + '-' + day
+ ' ' + d.getHours() + ':' + d.getMinutes() + ':' + d.getSeconds()
+ ' ' + d.getHours() + ':' + minutes + ':' + seconds
+ ' ' + get_time_zone_diff(d);

return formatted;
Expand Down
25 changes: 15 additions & 10 deletions js/dcc_review.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,22 +48,27 @@ function titleCase(str) {
return str.join(' ');
}

function pad_zeroes(number) {
if (number < 10) {
return '0' + number;
}
return number;
}

function get_formatted_date(d) {
// Returns a date as a string in the following format: "2020-10-09 17:32:32 - 0400"
var month = d.getMonth() + 1;

if (month < 10) {
month = '0' + month;
}

var day = d.getDate();
var minutes = d.getMinutes();
var seconds = d.getSeconds();

if (day < 10) {
day = '0' + day;
}
month = pad_zeroes(month);
day = pad_zeroes(day);
minutes = pad_zeroes(minutes)
seconds = pad_zeroes(seconds);

var formatted = d.getFullYear() + '-' + month + '-' + day
+ ' ' + d.getHours() + ':' + d.getMinutes() + ':' + d.getSeconds()
+ ' ' + d.getHours() + ':' + minutes + ':' + seconds
+ ' ' + get_time_zone_diff(d);

return formatted;
Expand Down Expand Up @@ -209,7 +214,7 @@ function add_summary_data(catalog_id, DCC, num_dccs) {

var chaise_uri = get_chaise_uri(catalog_id, name.toLowerCase(), data['RID']);
name = name.replace(/_/g, ' ');
$('#data_breakdown_table >> #' + key).html('<a href="' + chaise_uri + '">' + data[key].toLocaleString() + '</a>');
$('#data_breakdown_table >> #' + key).html('<a href="' + chaise_uri + '">' + data[key].toLocaleString() + '</a>');
}
});
});
Expand Down
25 changes: 15 additions & 10 deletions js/index.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,27 @@
/* global register_dropdowns update_chart */

// TODO - copied from dcc_review.js
// TODO - copied from dcc_review.js; put into a cental location
function pad_zeroes(number) {
if (number < 10) {
return '0' + number;
}
return number;
}

function get_formatted_date(d) {
// Returns a date as a string in the following format: "2020-10-09 17:32:32 - 0400"
var month = d.getMonth() + 1;

if (month < 10) {
month = '0' + month;
}

var day = d.getDate();
var minutes = d.getMinutes();
var seconds = d.getSeconds();

if (day < 10) {
day = '0' + day;
}
month = pad_zeroes(month);
day = pad_zeroes(day);
minutes = pad_zeroes(minutes)
seconds = pad_zeroes(seconds);

var formatted = d.getFullYear() + '-' + month + '-' + day
+ ' ' + d.getHours() + ':' + d.getMinutes() + ':' + d.getSeconds()
+ ' ' + d.getHours() + ':' + minutes + ':' + seconds
+ ' ' + get_time_zone_diff(d);

return formatted;
Expand Down
26 changes: 14 additions & 12 deletions js/pdashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,26 +108,28 @@ $('.scroller-left').click(function() {
});


// TODO - copied from dcc_review.js; put into a cental location
function pad_zeroes(number) {
if (number < 10) {
return '0' + number;
}
return number;
}

// TODO - copied from dcc_review.js
function get_formatted_date(d) {
// Returns a date as a string in the following format: "2020-10-09 17:32:32 - 0400"
var month = d.getMonth() + 1;

if (month < 10) {
month = '0' + month;
}

var day = d.getDate();
var minutes = d.getMinutes();
var seconds = d.getSeconds();

if (day < 10) {
day = '0' + day;
}
month = pad_zeroes(month);
day = pad_zeroes(day);
minutes = pad_zeroes(minutes)
seconds = pad_zeroes(seconds);

var formatted = d.getFullYear() + '-' + month + '-' + day
+ ' ' + d.getHours() + ':' + d.getMinutes();
// + ':' + d.getSeconds()
//+ ' ' + get_time_zone_diff(d);
+ ' ' + d.getHours() + ':' + minutes

return formatted;
}
Expand Down
25 changes: 15 additions & 10 deletions js/summary_graph.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,27 @@
/* global register_dropdowns update_chart */

// TODO - copied from dcc_review.js
// TODO - copied from dcc_review.js; put into a cental location
function pad_zeroes(number) {
if (number < 10) {
return '0' + number;
}
return number;
}

function get_formatted_date(d) {
// Returns a date as a string in the following format: "2020-10-09 17:32:32 - 0400"
var month = d.getMonth() + 1;

if (month < 10) {
month = '0' + month;
}

var day = d.getDate();
var minutes = d.getMinutes();
var seconds = d.getSeconds();

if (day < 10) {
day = '0' + day;
}
month = pad_zeroes(month);
day = pad_zeroes(day);
minutes = pad_zeroes(minutes)
seconds = pad_zeroes(seconds);

var formatted = d.getFullYear() + '-' + month + '-' + day
+ ' ' + d.getHours() + ':' + d.getMinutes() + ':' + d.getSeconds()
+ ' ' + d.getHours() + ':' + minutes + ':' + seconds
+ ' ' + get_time_zone_diff(d);

return formatted;
Expand Down

0 comments on commit 4d4c03a

Please sign in to comment.