Time/date transform in perspective table

Hi
Using perspective, I would like to display the 'scheduled events' data from an equipment schedule component in a table. I copied the binding, and all is fine....
except the format of the startDate and endDate fields. These come back as longs in milliseconds. I would like to convert them to date/time strings in the table.
So I use the following transform:

def transform(self, value, quality, timestamp):
								
	for row in value:
		system.perspective.print(row)
		new_start = row['startDate']
		new_end   = row['endDate']		
		new_values = {'startDate':new_start, 'endDate':new_end}
		
		row.update(new_values)
		system.perspective.print(row)

	return value

But I get an error "..... common.script.ada' object has no attribute update" referring to the row.update() line
It seems to me that the return value (Json) is a list of dictionaries, thus 'row' (dictionary) should have an update method.

What have I missed?
How would I achieve my objective?

Thanks in advance.

1 Like

That's generally a bad idea. Keep them as datetime type and just have them displayed in the format you want.

For Perspective's Table component you need to set each
columm.x.field : <columnName>
and then you can specifiy
column.x.render : date
which will use
column.x.dateFormat

Many of the column properties don't take effect if the field property is not set to the column name.

1 Like

Thanks Transistor,
you are are a genius
works a charm!
I searched all the options before posting, except that one!

Thanks champ!

Ahem! [Cough, cough!] You've marked your post as the solution. Shouldn't you have marked mine?

2 Likes

fixed