no-offsetdatetime
@azure-tools/typespec-azure-core/no-offsetdatetimePrefer using utcDateTime when representing a datetime unless an offset is necessary.
Prefer using utcDateTime when representing a datetime unless an offset is necessary. Most Azure services work with UTC times and offsetDateTime adds unnecessary complexity.
Impact
Section titled “Impact”- Area: SDK, API
Times are clearest when expressed in UTC; offsetDateTime obscures intent.
❌ Incorrect
Section titled “❌ Incorrect”As a model property:
model Bar { prop: offsetDateTime;}As an operation return type:
op getTimestamp(): offsetDateTime;As a union variant:
union TimeValue { a: offsetDateTime,}As a scalar extension:
scalar myDateTime extends offsetDateTime;✅ Correct
Section titled “✅ Correct”model Bar { prop: utcDateTime;}op getTimestamp(): utcDateTime;Suppression
Section titled “Suppression”Suppress when there is a clear rationale for offsetDateTime; otherwise use utcDateTime.