I've been testing out Azure's EventGrid and one of the things I'm trying to do is send an event where part of the PayLoad is a DateTimeOffset field. I'm publishing the event using the standard EventGridClient:
using (var client = new EventGridClient(topicCredentials))
{
await client.PublishEventsAsync(topicHostname, eventGridEvents).ConfigureAwait(false);
}
I've fired up Fiddler and verified that the date portion is getting serialized as I would expect: "CheckInDate": "2018-12-26T14:47:42.8-08:00"
But when my subscribed Azure Functions listener receives the HttpTrigger and reads the message's content, the same item has somehow been formatted as UTC: "CheckInDate": "2018-12-26T22:47:42.8+00:00".
Is there a setting or something I need to enable to get it to preserve the original offset?
Although working with UTC on the backend is usually the best practice (so I would consider keeping it unless there is a specific need to work with local time), I think you should try to store the offset in a dedicated field, and the just convert it back to the relevant local time on the receiving side using that offset.
Take a look at DateTimeOffset Struct on how you might be able to do the conversions.
Hope it helps!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.