TL.DateTimeExtensionsLibrary 0.2.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package TL.DateTimeExtensionsLibrary --version 0.2.0
                    
NuGet\Install-Package TL.DateTimeExtensionsLibrary -Version 0.2.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="TL.DateTimeExtensionsLibrary" Version="0.2.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="TL.DateTimeExtensionsLibrary" Version="0.2.0" />
                    
Directory.Packages.props
<PackageReference Include="TL.DateTimeExtensionsLibrary" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add TL.DateTimeExtensionsLibrary --version 0.2.0
                    
#r "nuget: TL.DateTimeExtensionsLibrary, 0.2.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package TL.DateTimeExtensionsLibrary@0.2.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=TL.DateTimeExtensionsLibrary&version=0.2.0
                    
Install as a Cake Addin
#tool nuget:?package=TL.DateTimeExtensionsLibrary&version=0.2.0
                    
Install as a Cake Tool

📅 TL.DateTimeExtensionsLibrary

NuGet .NET License: MIT ADR

O TL.DateTimeExtensionsLibrary oferece uma suíte de utilitários de alta performance para System.DateTime, simplificando cálculos de dias úteis em tempo constante $O(1)$, fatiamento temporal de intervalos (Chunks), limites de calendário e formatações especializadas com total preservação do DateTimeKind.


📦 Instalação

Adicione o pacote ao seu projeto através do .NET CLI:

dotnet add package TL.DateTimeExtensionsLibrary

🚀 Funcionalidades Principais

Dias Úteis e Prazos

Método Retorno Descrição
AddBusinessDays(days) DateTime Adiciona dias úteis ignorando finais de semana com integridade de timezone.
BusinessDaysBetween(endDate) int Calcula o total de dias úteis em $O(1)$ sem loops iterativos.
IsBusinessDay() bool Retorna se a data atual corresponde a um dia útil (segunda a sexta).
IsWeekend() bool Verifica se a data corresponde a sábado ou domingo.
NextBusinessDay() DateTime Obtém o próximo dia útil subsequente.

Calendário e Particionamento de Intervalos

Método Retorno Descrição
Chunks(endDate, days) IEnumerable<Tuple<DateTime, DateTime>> Divide intervalos longos em lotes menores para consultas paginadas e jobs em lote.
StartOfMonth() / EndOfMonth() DateTime Retorna o início (00:00:00.000) ou fim (23:59:59.999) do mês.
StartOfWeek() / EndOfWeek() DateTime Retorna o primeiro ou último momento da semana.
Age() int Calcula a idade exata com base na data atual ou especificada.
DaysUntil(target) int Retorna a contagem de dias corridos até a data alvo.

Formatações Especializadas

Método Retorno Descrição
ToFriendlyDateString() string Retorna texto humanizado (ex: "hoje", "ontem", "há 3 dias").
ToISO8601() string Converte para a representação universal padrão ISO 8601.
ToOrdinalDateString() string Converte para texto ordinal (ex: "1st", "2nd", "3rd").

💡 Exemplos de Uso

using System;
using DateTimeExtensionsLibrary;

public class ServicoPrazos
{
    public void ExecutarExemplos()
    {
        DateTime hoje = DateTime.UtcNow;

        // 1. Cálculo de Prazos e Vencimentos Úteis
        DateTime vencimento = hoje.AddBusinessDays(10);
        int diasUteisRestantes = hoje.BusinessDaysBetween(vencimento);

        // 2. Fatiamento de Consultas Massivas por Lotes de 7 dias
        DateTime inicioAno = new DateTime(2026, 1, 1, 0, 0, 0, DateTimeKind.Utc);
        DateTime fimAno = new DateTime(2026, 12, 31, 0, 0, 0, DateTimeKind.Utc);

        foreach (var (inicio, fim) in inicioAno.Chunks(fimAno, 7))
        {
            Console.WriteLine($"Consultando período: {inicio:yyyy-MM-dd} até {fim:yyyy-MM-dd}");
        }
    }
}

🏛️ Decisões Arquiteturais

Para detalhes sobre a complexidade algorítmica $O(1)$ de dias úteis e preservação de fuso horário, consulte:


📄 Licença

Distribuído sob a licença MIT.

Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  net5.0-windows was computed.  net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net5.0

    • No dependencies.
  • net6.0

    • No dependencies.
  • net8.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on TL.DateTimeExtensionsLibrary:

Package Downloads
TL.ExtensionLibrary.Domain

Clean Architecture Domain metapackage: pure, high-performance domain extensions (String, Numeric, DateTime, Enum, Collection) with zero external infrastructure dependencies.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.8.0 199 10/1/2026
0.7.0 196 9/26/2026
0.6.0 197 9/22/2026
0.5.0 206 9/16/2026
0.4.2 214 9/16/2026
0.4.1 203 9/11/2026
0.4.0 219 9/6/2026
0.3.0 120 9/6/2026
0.2.0 117 9/5/2026
0.1.0 118 9/4/2026
0.0.1 198 10/17/2024