Fixed time stamp

master
dabbott 1 year ago
parent 64e533d6b9
commit ef585295fb

@ -1,30 +1,40 @@
fetch = require("node-fetch") fetch = require("node-fetch")
// process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0" process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0"
cookie = "cookie!" cookie = "timesheets=s%3A8OD5JBpF-Xt2XnETidIulrB3t0zx7hyM.COWXDBh6q%2BzYIAZaBEzP1JipOuy9UgIRKydvlrC0rUE"
oncArr = [ oncArr = [
{ {
year:2022, year:2023,
month: 01, month: 02,
day: 01 day: 17
}, },
{ {
year:2022, year:2023,
month: 01, month: 03,
day: 14 day: 10
}, },
{ {
year:2022, year:2023,
month: 02, month: 03,
day: 04 day: 31
}, },
{ {
year:2022, year:2023,
month: 02, month: 04,
day: 25 day: 21
},
{
year:2023,
month: 05,
day: 12
},
{
year:2023,
month: 06,
day: 02
} }
] ]
@ -34,15 +44,17 @@ function makeArr(startDateObj,username, password){
dateArr =[] dateArr =[]
postDataObj = {} postDataObj = {}
i = 7 i = 7
re = /(.*)T/
while (i != 0) { while (i != 0) {
day = new Date(dateMs) day = new Date(dateMs)
postDataObj = {teamId:10, postDataObj = {teamId:null,
date:day, date:day.toISOString().substring(0, 10),
startTime:"17:30", startTime:"17:30",
endTime:"07:00"} endTime:"07:00"}
switch (day.getDay()) { switch (day.getDay()) {
case 0: case 0:
postDataObj.startTime="00:00" postDataObj.startTime="00:00"
postDataObj.endTime="00:00" postDataObj.endTime="00:00"
@ -58,14 +70,14 @@ function makeArr(startDateObj,username, password){
dateArr.push(postDataObj) dateArr.push(postDataObj)
break; break;
case 1: case 1:
postDataObj = {teamId:10, postDataObj = {teamId:null,
date:day, date:day.toISOString().substring(0, 10),
startTime:"00:00", startTime:"00:00",
endTime:"07:00"} endTime:"07:00"}
dateArr.push(postDataObj) dateArr.push(postDataObj)
postDataObj = {teamId:10, postDataObj = {teamId:null,
date:day, date:day.toISOString().substring(0, 10),
startTime:"17:30", startTime:"17:30",
endTime:"07:00"} endTime:"07:00"}
dateArr.push(postDataObj) dateArr.push(postDataObj)
@ -82,6 +94,7 @@ function makeArr(startDateObj,username, password){
} }
async function dateSend(dateArr, cookie) { async function dateSend(dateArr, cookie) {
console.log(dateArr)
fetch('https://timesheets.node4.co.uk/api/on-call', { fetch('https://timesheets.node4.co.uk/api/on-call', {
method: 'post', method: 'post',
body: JSON.stringify(dateArr), body: JSON.stringify(dateArr),

Loading…
Cancel
Save