How to set milliseconds in custom column?

I am trying to display a datetime column with milliseconds, but I can't get the formatting right, so it seems.

This shows the current time nicely with milliseconds:

scriptColData.value = DOpus.Create().Date();

This works with normal seconds:

scriptColData.value = DOpus.Create().Date('20010203 12:34:56');

I expected this to work, but it didn't:

scriptColData.value = DOpus.Create().Date('20010203 12:34:56.789');
function OnInit(initData) {
  initData.name = 'CurrentTime';
  initData.version = '2021-04-21';
  initData.copyright = '';
  initData.url = 'https://resource.dopus.com';
  initData.desc = '';
  initData.default_enable = true;
  initData.min_version = '12.0';
}

function OnAddColumns(addColData) {
  var col = addColData.AddColumn();
  col.name = 'CurrentTime';
  col.label = 'CurrentTime';
  col.header = 'CurrentTime';
  col.justify = 'right';
  col.type = 'datetime';
  col.autogroup = true;
  col.method = 'OnColumn';
}

function OnColumn(scriptColData) {
  // scriptColData.value = DOpus.Create().Date(); // works with milliseconds!
  // scriptColData.value = DOpus.Create().Date('20010203 12:34:56'); // works!
  scriptColData.value = DOpus.Create().Date('20010203 12:34:56.789');
}

ColumnCurrentTime.js.txt (816 Bytes)

I haven't checked if the format in your Date('...') works but if you add .Format('', 'M') at the end, you get milliseconds, e.g. .Date().Format('t', 'M')

This is what I get. The milliseconds are missing :frowning:

image

But they are there when I use the Date() method:

image

The problem seems to be with the parameter for DOpus' own Date() constructor; not sure if it's a bug or not. I've tried several notations, none but 1 worked. This one is ugly but it works.

Milliseconds weren't supported in time/datetime strings there, but we'll make that work in the next beta.

2 Likes

That change is in the beta released today: Directory Opus 12.24.1 (Beta)

Is there something wrong with my format coding for str2? Given the "M" flag I would expect to see milliseconds appended to the 24 hour format.

Probably.

If you wish for milliseconds to be included, begin the time format with an M (capital-m) character. For example, {time|MHH:mm:ss} will return a time similar to "08:45:32.021".

https://www.gpsoft.com.au/help/opus12/index.html#!Documents/Codes_for_date_and_time.htm

1 Like

Good grief. I actually read that link before posting but evidently missed the most relevant part of the instructions. Thanks @lxp for pointing out what should have been evident.

is there a way to add milliseconds to the runtime colum in movies?

I don't think this column has a millisecond resolution. It could be calculated based on frame rate and count.