Skip to content

Commit

Permalink
Use ISO 8601 for UTC timestamps sent to IoT Hub (#6832) (#6839)
Browse files Browse the repository at this point in the history
IoT Hub requires UTC timestamps to end with 'Z' (ISO 8601); otherwise, it will interpret the timestamp as local time. This PR changes aziot-edged and edgeAgent to serialize to ISO 8601.
  • Loading branch information
gordonwang0 authored Jan 17, 2023
1 parent af1b96c commit 0ab44e1
Show file tree
Hide file tree
Showing 6 changed files with 402 additions and 289 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,13 @@ public DockerRuntimeModule(
IDictionary<string, EnvVal> env)
: base(name, version, desiredStatus, restartPolicy, config, imagePullPolicy, startupOrder, configuration, env)
{
// IoT Hub requires UTC timestamps; all timestamps in this struct must have timezone UTC.
this.ExitCode = exitCode;
this.StatusDescription = statusDescription;
this.LastExitTimeUtc = lastExitTime;
this.LastStartTimeUtc = lastStartTime;
this.LastExitTimeUtc = lastExitTime.ToUniversalTime();
this.LastStartTimeUtc = lastStartTime.ToUniversalTime();
this.RestartCount = Preconditions.CheckRange(restartCount, 0, nameof(restartCount));
this.LastRestartTimeUtc = lastRestartTime;
this.LastRestartTimeUtc = lastRestartTime.ToUniversalTime();
this.RuntimeStatus = Preconditions.CheckIsDefined(runtimeStatus);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,13 @@ public TestRuntimeModule(
IDictionary<string, EnvVal> env = null)
: base(name, version, type, desiredStatus, config, restartPolicy, imagePullPolicy, startupOrder, deploymentInfo, env)
{
// IoT Hub requires UTC timestamps; all timestamps in this struct must have timezone UTC.
this.ExitCode = exitCode;
this.StatusDescription = statusDescription;
this.LastStartTimeUtc = lastStartTimeUtc;
this.LastExitTimeUtc = lastExitTimeUtc;
this.LastStartTimeUtc = lastStartTimeUtc.ToUniversalTime();
this.LastExitTimeUtc = lastExitTimeUtc.ToUniversalTime();
this.RestartCount = restartCount;
this.LastRestartTimeUtc = lastRestartTimeUtc;
this.LastRestartTimeUtc = lastRestartTimeUtc.ToUniversalTime();
this.RuntimeStatus = runtimeStatus;
}

Expand Down
Loading

0 comments on commit 0ab44e1

Please sign in to comment.