Handling Date and Time Values

Handling Date and Time Values

Telerik Platform supports date and time values natively. In the Backend Services .NET SDK, those values are represented as DateTime objects.

Handling Values in Local Time and UTC

Telerik Platform always stores date and time values in UTC. If you send it a value in local time, it converts it to UTC before storing it. When you read date and time values from the server, the SDK automatically converts them to local date and time.

You can change the default behavior by setting properties when creating the EverliveAppobject. The next example sets InboundDateTimeProcessing to DateTimeValuesProcessing.NoChanges. This tells the SDK that you don't want any processing to be applied on data that you read from the server which is always stored in UTC.

var settings = new EverliveAppSettings()
    ApiKey = "your-app-id",
    InboundDateTimeProcessing = DateTimeValuesProcessing.NoChanges
EverliveApp app = new EverliveApp(settings);

The properties that you can set to control date and time value processing are listed in the table below.

Unless you have a specific requirement not to do so, we recommend using the default behavior. It is the most convenient mode when the same data set is consumed from thousands of devices in various time zones.

Date and Time Value Control Properties
Propety Name Description
`InboundDateTimeProcessing` Controls how to handle date and time values that you read from the server.
`OutboundDateTimeProcessing` Deprecated* Controls how to handle date and time values that you write to the server.
* Setting this property has no effect anymore as all values are converted to UTC on the server anyway.

The InboundDateTimeProcessing and OutboundDateTimeProcessing properties can take these values:

InboundDateTimeProcessing and OutboundDateTimeProcessing Values
Propety Value Description
`DateTimeValuesProcessing.NoChanges` Date and time values are not processed.
`DateTimeValuesProcessing.ConvertToLocal` All date and time values are converted to local time.
`DateTimeValuesProcessing.ConvertToUtc` All date and time values are converted to UTC.

Handling Unspecified Values

Another important setting is related to handling unspecified DateTime objects. These objects have their Kind set to Unspecified. Such values are not supported by Telerik Platform and you must process them before sending them.

The default setting is to throw an exception when an unspecified date is encountered. You are encouraged to keep this setting and always work in either UTC or local time. However, if you need to work with unspecified dates, you can use the DateTimeUnspecifiedHandling property that automatically treats these as either UTC or Local. You can set it when creating the EverliveAppSettings object.

The next table lists the DateTimeUnspecifiedHandling property's possible values.

DateTimeUnspecifiedHandling Values
Propety Values Description
`DateTimeUnspecifiedHandling.ThrowException` Throws an exception on encountering unspecified DateTime objects.
`DateTimeUnspecifiedHandling.TreatAsLocal` Assumes that all unspecified DateTime objects are in local time.
`DateTimeUnspecifiedHandling.TreatAsUtc` Assumes that all unspecified DateTime objects are in UTC.

The example below shows how to set DateTimeUnspecifiedHandling to DateTimeUnspecifiedHandling.TreatAsLocal, requesting all unspecified values to be treated as local time.

var settings = new EverliveAppSettings()
    ApiKey = "your-app-id",
    DateTimeUnspecifiedHandling = DateTimeUnspecifiedHandling.TreatAsLocal

EverliveApp app = new EverliveApp(settings);

See Also

Start a free trial Request a demo
Contact us: +1-888-365-2779
Copyright © 2016-2017, Progress Software Corporation and/or its subsidiaries or affiliates. All rights reserved.