CKTIS / C#
dates and time: praktična referenca
dates and time: praktična referenca: Čas loči trenutek, lokalni datum, območje, odmik in trajanje.
Različica: C# language and .NET 10 reference runtime
Sintaksa
// timeČas loči trenutek, lokalni datum, območje, odmik in trajanje.
Trenutke shranjujte v UTC ali DateTimeOffset, območje pa kot ločeno poslovno pravilo.
Stenska ura se lahko vrne; za intervale uporabite monotoni Stopwatch ali TimeProvider.
DST ustvari neobstoječe in dvoumne čase, obsegi tipov pa so omejeni.
Celoten program dejansko uporabi dates and time; natančno pričakovani stdout je 2026-11-18.
Primeri
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 date = new DateOnly(2026, 11, 17); Console.WriteLine(date.AddDays(1).ToString("yyyy-MM-dd", CultureInfo.InvariantCulture));
Rezultat
2026-11-18
Celoten program dejansko uporabi `dates and time`; natančno pričakovani stdout je `2026-11-18`.