diff --git a/js/dashboard.js b/js/dashboard.js index d1bf7fe..6096fea 100644 --- a/js/dashboard.js +++ b/js/dashboard.js @@ -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; diff --git a/js/dcc_review.js b/js/dcc_review.js index 8812055..588d5b7 100644 --- a/js/dcc_review.js +++ b/js/dcc_review.js @@ -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; @@ -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('' + data[key].toLocaleString() + ''); + $('#data_breakdown_table >> #' + key).html('' + data[key].toLocaleString() + ''); } }); }); diff --git a/js/index.js b/js/index.js index c2ac772..883e5ea 100644 --- a/js/index.js +++ b/js/index.js @@ -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; diff --git a/js/pdashboard.js b/js/pdashboard.js index 8315993..86b4b2f 100644 --- a/js/pdashboard.js +++ b/js/pdashboard.js @@ -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; } diff --git a/js/summary_graph.js b/js/summary_graph.js index b4b5fb7..c010f4b 100644 --- a/js/summary_graph.js +++ b/js/summary_graph.js @@ -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;