CKTIS / C#
System.DateTimeOffset: riferimento pratico
System.DateTimeOffset: riferimento pratico: DateTimeOffset combina un orario con un offset e identifica quindi un istante non ambiguo.
Versione: .NET API; verified on .NET 10.0.14
Sintassi
System.DateTimeOffset /* select a documented member or constructor */DateTimeOffset combina un orario con un offset e identifica quindi un istante non ambiguo.
Usalo per timestamp scambiati tra sistemi mantenendo l’offset osservato.
Un offset non è un identificatore di fuso e non conserva le sue regole storiche dell’ora legale.
Deve rientrare tra meno e più quattordici ore in minuti interi e anche l’istante UTC deve essere valido.
Il programma completo usa realmente System.DateTimeOffset; lo stdout esatto atteso è +01:00.
Esempi
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));
Risultato
+01:00
Il programma completo usa realmente `System.DateTimeOffset`; lo stdout esatto atteso è `+01:00`.