all dates in gui are in market time zone (even start/stop)

This commit is contained in:
David Brazda
2024-02-27 10:53:30 +07:00
parent ca1172c61c
commit 17cb63f792
4 changed files with 33 additions and 18 deletions

View File

@ -1150,7 +1150,7 @@
<!-- <script src="/static/js/utils.js?v=1.01"></script> --> <!-- <script src="/static/js/utils.js?v=1.01"></script> -->
<!-- new util structure and exports and colors --> <!-- new util structure and exports and colors -->
<script src="/static/js/utils/utils.js?v=1.04"></script> <script src="/static/js/utils/utils.js?v=1.05"></script>
<script src="/static/js/utils/exports.js?v=1.04"></script> <script src="/static/js/utils/exports.js?v=1.04"></script>
<script src="/static/js/utils/colors.js?v=1.04"></script> <script src="/static/js/utils/colors.js?v=1.04"></script>
@ -1160,13 +1160,13 @@
<!-- <script src="/static/js/archivetables.js?v=1.05"></script> --> <!-- <script src="/static/js/archivetables.js?v=1.05"></script> -->
<!-- archiveTables split into separate files --> <!-- archiveTables split into separate files -->
<script src="/static/js/tables/archivetable/init.js?v=1.10"></script> <script src="/static/js/tables/archivetable/init.js?v=1.11"></script>
<script src="/static/js/tables/archivetable/functions.js?v=1.09"></script> <script src="/static/js/tables/archivetable/functions.js?v=1.09"></script>
<script src="/static/js/tables/archivetable/modals.js?v=1.07"></script> <script src="/static/js/tables/archivetable/modals.js?v=1.07"></script>
<script src="/static/js/tables/archivetable/handlers.js?v=1.07"></script> <script src="/static/js/tables/archivetable/handlers.js?v=1.07"></script>
<!-- Runmanager functionality --> <!-- Runmanager functionality -->
<script src="/static/js/tables/runmanager/init.js?v=1.10"></script> <script src="/static/js/tables/runmanager/init.js?v=1.1"></script>
<script src="/static/js/tables/runmanager/functions.js?v=1.08"></script> <script src="/static/js/tables/runmanager/functions.js?v=1.08"></script>
<script src="/static/js/tables/runmanager/modals.js?v=1.07"></script> <script src="/static/js/tables/runmanager/modals.js?v=1.07"></script>
<script src="/static/js/tables/runmanager/handlers.js?v=1.07"></script> <script src="/static/js/tables/runmanager/handlers.js?v=1.07"></script>

View File

@ -70,30 +70,32 @@ function initialize_archiveRecords() {
{ {
targets: [5], targets: [5],
render: function ( data, type, row ) { render: function ( data, type, row ) {
now = new Date(data)
if (type == "sort") { if (type == "sort") {
return new Date(data).getTime(); return new Date(data).getTime();
} }
//data = "2024-02-26T19:29:13.400621-05:00"
// Create a date object from the string, represents given moment in time in UTC time
var date = new Date(data); var date = new Date(data);
tit = date.toLocaleString('cs-CZ', { tit = date.toLocaleString('cs-CZ', {
timeZone: 'America/New_York', timeZone: 'America/New_York',
}) })
if (isToday(now)) { if (isToday(date)) {
console.log("volame isToday s", date)
//return local time only //return local time only
return '<div title="'+tit+'">'+ 'dnes ' + format_date(data,false,true)+'</div>' return '<div title="'+tit+'">'+ 'dnes ' + format_date(data,true,true)+'</div>'
} }
else else
{ {
//return local datetime //return local datetime
return '<div title="'+tit+'">'+ format_date(data,false,false)+'</div>' return '<div title="'+tit+'">'+ format_date(data,true,false)+'</div>'
} }
}, },
}, },
{ {
targets: [6], targets: [6],
render: function ( data, type, row ) { render: function ( data, type, row ) {
now = new Date(data)
if (type == "sort") { if (type == "sort") {
return new Date(data).getTime(); return new Date(data).getTime();
} }
@ -102,14 +104,14 @@ function initialize_archiveRecords() {
timeZone: 'America/New_York', timeZone: 'America/New_York',
}) })
if (isToday(now)) { if (isToday(date)) {
//return local time only //return local time only
return '<div title="'+tit+'" class="token level comment">'+ 'dnes ' + format_date(data,false,true)+'</div>' return '<div title="'+tit+'" class="token level comment">'+ 'dnes ' + format_date(data,true,true)+'</div>'
} }
else else
{ {
//return local datetime //return local datetime
return '<div title="'+tit+'" class="token level number">'+ format_date(data,false,false)+'</div>' return '<div title="'+tit+'" class="token level number">'+ format_date(data,true,false)+'</div>'
} }
}, },
}, },

View File

@ -168,7 +168,6 @@ function initialize_runmanagerRecords() {
targets: [15,17, 18, 8, 9], //start, stop, valid_from, valid_to, bt_from, bt_to, last_proccessed targets: [15,17, 18, 8, 9], //start, stop, valid_from, valid_to, bt_from, bt_to, last_proccessed
render: function ( data, type, row ) { render: function ( data, type, row ) {
if (!data) return data if (!data) return data
now = new Date(data)
if (type == "sort") { if (type == "sort") {
return new Date(data).getTime(); return new Date(data).getTime();
} }

View File

@ -990,12 +990,26 @@ JSON.safeStringify = (obj, indent = 2) => {
return retVal; return retVal;
}; };
function isToday(someDate) {
const today = new Date() function isToday(someDate) {
return someDate.getDate() == today.getDate() && // Convert input date to Eastern Time
someDate.getMonth() == today.getMonth() && var dateInEastern = new Date(someDate.toLocaleString('en-US', { timeZone: 'America/New_York' }));
someDate.getFullYear() == today.getFullYear() console.log("vstupuje ",someDate)
} console.log("americky ",dateInEastern)
// Get today's date in Eastern Time
var todayInEastern = new Date(new Date().toLocaleString('en-US', { timeZone: 'America/New_York' }));
return dateInEastern.getDate() === todayInEastern.getDate() &&
dateInEastern.getMonth() === todayInEastern.getMonth() &&
dateInEastern.getFullYear() === todayInEastern.getFullYear();
}
// function isToday(someDate) {
// const today = new Date()
// return someDate.getDate() == today.getDate() &&
// someDate.getMonth() == today.getMonth() &&
// someDate.getFullYear() == today.getFullYear()
// }
//https://www.w3schools.com/jsref/jsref_tolocalestring.asp //https://www.w3schools.com/jsref/jsref_tolocalestring.asp
function format_date(datum, markettime = false, timeonly = false) { function format_date(datum, markettime = false, timeonly = false) {