CKTIS / C#
System.DateTimeOffset: referencia práctica
System.DateTimeOffset: referencia práctica: DateTimeOffset combina una hora con un desplazamiento y por ello identifica un instante inequívoco.
Versión: .NET API; verified on .NET 10.0.14
Sintaxis
System.DateTimeOffset /* select a documented member or constructor */DateTimeOffset combina una hora con un desplazamiento y por ello identifica un instante inequívoco.
Úsalo para marcas de tiempo intercambiadas entre sistemas conservando el desplazamiento observado.
Un desplazamiento no es un identificador de zona ni conserva sus reglas históricas de horario de verano.
Debe estar entre menos y más catorce horas en minutos enteros y el instante UTC resultante debe ser válido.
El programa completo usa realmente System.DateTimeOffset; su stdout esperado exacto es +01:00.
Ejemplos
using System;
using System.Buffers;
using System.Collections.Concurrent;
using System.Collections.Frozen;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text;
using System.Text.Json;
using System.Text.Json.Nodes;
using System.Text.Json.Serialization;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Channels;
using System.Threading.Tasks;
using Number = System.Int32;
var instant = new DateTimeOffset(2026, 11, 17, 12, 0, 0, TimeSpan.FromHours(1));
Console.WriteLine(instant.ToString("zzz", CultureInfo.InvariantCulture));
Resultado
+01:00
El programa completo usa realmente `System.DateTimeOffset`; su stdout esperado exacto es `+01:00`.