Skip to content

Amazon.CloudWatch.Model.MetricDatum timestamp is not set correctly #3333

Discussion options

You must be logged in to vote

Hi @bhoradc,

Thank you so much!!!

I will put my solution here, maybe it will help somebody else.

Before:
When inspecting TimestampUtc the date time seemed to be correct, but the DateTimeKind was wrong!!!
point.timestamp is a long storing the utc timestamp in seconds

TimestampUtc = DateTimeOffset.FromUnixTimeSeconds(point.timestamp).DateTime;

After:
Notice the explicit specification of the DateTimeKind.

var time = DateTimeOffset.FromUnixTimeSeconds(point.timestamp).DateTime;
TimestampUtc = DateTime.SpecifyKind(time, DateTimeKind.Utc);

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by bhoradc
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
guidance Question that needs advice or information.
2 participants
Converted from issue

This discussion was converted from issue #3329 on June 05, 2024 12:54.