Updating a Duration Field by Plugin

╄→гoц情女王★ 提交于 2019-12-24 12:08:45

问题


Has anyone had to update a Duraton field from within a plugin?

On the UI it is fairly intelligent, you can type

  • 5 minutes
  • 7 //defaults to minutes
  • 3 hours

And it will workout what you need.

Assuming the field is called new_foo, what value should I assign? Int?

var e = new Entity("new_bar");
e.Attributes("new_foo", 5);//5 minutes?

Double?

var e = new Entity("new_bar");
e.Attributes("new_foo", 5.00);//5 minutes?

Other ideas?


回答1:


Duration is a format for the Whole Number type, so by code you need to set an Int32 value (in this case not negative or it will throw an exception)

The value is always considered in minutes, so if you want to put 3 hours you need to set the field value to 180 (60 minutes x 3 hours), 1 day is 1440 (60 minutes x 24 hours) and so on.

By interface you can set using decimals, but it's always a representation of an integer value (for example 1.5 hours equals 90 minutes)



来源:https://stackoverflow.com/questions/16148303/updating-a-duration-field-by-plugin

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!