CKTIS / C#
System.TimeOnly: odniesienie praktyczne
System.TimeOnly: odniesienie praktyczne: TimeOnly reprezentuje porę dnia bez daty, strefy i przesunięcia.
Wersja: .NET API; verified against .NET 10 reference surface
Składnia
System.TimeOnly /* select a documented member or constructor */TimeOnly reprezentuje porę dnia bez daty, strefy i przesunięcia.
Stosuj do godzin otwarcia i harmonogramów cyklicznych niezwiązanych z konkretną datą.
Nie jest chwilą na osi czasu; do konwersji potrzebujesz daty i strefy.
Add może zawinąć przez północ; zakres obejmuje jedną dobę.
Kompletny program rzeczywiście używa System.TimeOnly; oczekiwany stdout to dokładnie 14:30.
Przykłady
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 time = new TimeOnly(14, 30);
Console.WriteLine(time.ToString("HH:mm", CultureInfo.InvariantCulture));
Wynik
14:30
Kompletny program rzeczywiście używa `System.TimeOnly`; oczekiwany stdout to dokładnie `14:30`.