Date Time

The Date component is used to display a single date, time, or datetime to users. The different date types are displayed as options when creating the field, the default display type being date.

Date user control
Time user control
Date time user control

When the Time or DateTime display option is being used, time-zone conversions will be done. This means that wen selecting a value, you’re specifying the value in your time-zone and when saved it will be converted to UTC and when the value is being read from the database it will convert it from UTC to your machines local time-zone.

When the Date display option is being used no time-zone conversion will be done.

Component Code

The first section of the code for the component contains the standard parameter set along with the variables needed for the component to function. Following the variables are the methods used by the component which are listed below.

OnParametersSetAsync()

This method is called when the component is initialized and when there’s an update to the parent component. Its purpose is to assign values to all the variable in the component.

ValueChanged()

This method is called when the value of the date or time field has changed. This method ensures there are no validation errors, if the field is modifiable. If those conditions are met then the ChangeXML method is called, otherwise nothing happens.

ChangeXML()

This method is used to update the XML of the instance to reflect the value of the datetime field. When called the required XML is generated, the element name is equal to the XMLName variable, and the current value of the field represented as the ValueUX variable. The required XML is generated and saved in the correct format for the data type using a switch statement that corresponds to the 3 date types this component handles.

Lastly, a call is made to the ChangeField method on myInstance and the new XML is passed. If auto postback is enabled, it will also save the current instance and reload it.

Here is an example of the XML structure that is saved:

<DateTimeField>2022-12-27 19:09:37</DateTimeField>
Updated on December 11, 2023

Was this article helpful?

Related Articles

Need Support?
Can’t find the answer you’re looking for? Don’t worry we’re here to help!
Contact Support

Leave a Comment