Skip to content

Commit

Permalink
Prevented unintended timezone shift
Browse files Browse the repository at this point in the history
  • Loading branch information
mmcev106 committed Dec 19, 2022
1 parent 9f438c4 commit 78ea573
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions CrossprojectpipingExternalModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -529,15 +529,15 @@ function runCrossProjectPiping() {
}
dFFormat = dFFormatArr.join('-');

const datepickerDate = new Date(data)
const dataParams = data.split(' ')
const datepickerDate = new Date(dataParams[0])
datepickerDate.setTime(datepickerDate.getTime()+datepickerDate.getTimezoneOffset()*60000) // Fix any timezone vs. UTC related date shifting

var newDate = $.datepicker.formatDate(dFFormat, datepickerDate);

if(!newDate.includes('NaN') && data.length >= 1) {
var dateTimeStr = '';
if(dateFormatParams[0] == 'datetime') {
const dataParams = data.split(' ')
let dateTimeData
if(dataParams.length === 1){
dateTimeData = []
Expand Down Expand Up @@ -603,6 +603,22 @@ function runCrossProjectPiping() {
time: '06:07',
seconds: '08'
}
},
{
/**
* Make sure timezone adjustment does not shift times later in the day
* over into the next day
*/
input: '2022-11-13 19:34',
outputs: {
date: {
dmy: '13-11-2022',
mdy: '11-13-2022',
ymd: '2022-11-13'
},
time: '19:34',
seconds: '00'
}
}
]

Expand Down

0 comments on commit 78ea573

Please sign in to comment.