While setting the start and end in the response body, the input is in IST. But the created entry has start time and end time as 5.5 hours ahead which is probably in UTC. If I try to retrieve the same time entry through API and check the start time and end time in the response body, it is the same which I entered. For example, if I have entered the start time as 12 PM IST and the end time as 1 PM IST, it is shown as 17.30 & 18.30 respectively.
Here is the code I am using to make the API call:
// Get the start time and end time from workflow variables
const startDateTime = workflow.taskStartDateTime;
const stopDateTime = workflow.taskStopDateTime;
// Get task ID and tag ID from tables
const taskName = workflow.currentProjectTask
const taskRecord = await ListOfTasksTable.findRecords({ filter: { 'Task Name': taskName } })
const taskId = _.get(taskRecord, '[0].Task ID')
const tagName = workflow.taskTags
const tagRecord = await ListofTagsTable.findRecords({ filter: { 'Tag Name': tagName } })
const tagId = _.get(tagRecord, '[0].Tag ID')
const entryDescription = workflow.taskDescription;
const projectId = bot.currentProjectId;
const activeWorkspaceID = bot.activeWorkspaceID;
// Update the data object with required parameters
const data = {
start: startDateTime,
end: stopDateTime,
description: entryDescription,
projectId: projectId,
tagIds: [tagId],
taskId: taskId
}
const axiosConfig = {
headers: {
'X-Api-Key': user.clockifyApiKey,
'Content-Type': 'application/json'
}
}
// Make a POST request to create a time entry in Clockify
const response = await axios.post(
`https://api.clockify.me/api/v1/workspaces/${activeWorkspaceID}/time-entries`,
data,
axiosConfig
)
// Check if the time entry was created successfully
if (response.status === 201) {
workflow.createEntryResponse = 'Time entry created successfully'
} else {
workflow.createEntryResponse = 'Failed to create time entry'
}
I've tried subtracting 5.5 hours from my input, converting from IST to UTC, converting UTC to IST. None of these seem to work. I don't know if I'm doing it wrong or it's just a wrong approch to a solution.