There is limited guidance for CosmosDB stored procedures and their processing new Date()and date comparisons.
The following code is a CosmosDB stored procedure for freezing documents after a specified time. The property currentDoc.FreezeDateis in the format ISO-8601, for example .. '2017-11-15T13: 34: 04Z
Note: this is an example of a situation that I am trying to understand. This is not production code.
function tryUpdate(newDoc) {
__.queryDocuments(
__.getSelfLink(),
{ },
(error, results) => {
var currentDoc = results[0];
if (new Date(currentDoc.FreezeDate) < new Date()) {
getContext().getResponse().setBody({ success: false });
return;
}
}
);
}
My question is: inside CosmosDB stored procedures, it new Date()affects time zones, especially considering that the database may be in a different region than the calling code? Is the date comparison code valid in all situations?