Date Object doesn't persist


I'm trying to persist a date object, the GlobalVars script shows that is has persisted, but it doesn't survive a restart. Could you point to what I'm doing wrong.

var obj = DOpus.create;
try {
    var prev_eta = DOpus.vars.get("ETA");
} catch(err) {
    var prev_eta = obj.Date('9999-12-31 23:59:59');
	DOpus.vars.set("ETA", prev_eta);
	DOpus.vars("ETA").persist = true;

Also, I thought to convert it toString() but that method also doesn't work.

We'll add support for saving Opus's Date objects in the future.

At the moment, it only works with the scripting language's native date format (VT_DATE).

You can convert an Opus date into a JScript date like this:

var opusDate = DOpus.Create.Date('9999-12-17 23:59:59');
var jsDate = new Date(opusDate);

If you need to convert the other way:

var jsDate = new Date();
var opusDate = DOpus.Create.Date(jsDate);

Thanks Leo. This helps. I convert this to a string before saving and load it back to a date.

You can persist a JScript Date as-is without converting to/from a string, FWIW.