🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

AaTurpin.Utilities

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

AaTurpin.Utilities

A comprehensive .NET utility library providing robust helper methods for common DateTime operations with ISO 8601 compliance and advanced file path manipulations including path normalization, UNC path handling, and safe path conversions.

1.0.0
Source
NuGet
Version published
Maintainers
1
Created
Source

AaTurpin.Utilities

A comprehensive .NET utility library providing robust helper methods for common DateTime and file path operations.

Installation

Install the package via NuGet Package Manager:

Install-Package AaTurpin.Utilities

Or via the .NET CLI:

dotnet add package AaTurpin.Utilities

Features

DateTimeUtils

Static utility class for common DateTime operations with ISO 8601 compliance:

  • Get first day of week (using ISO 8601 standard where Monday is the first day)
  • Get last day of week (using ISO 8601 standard where Sunday is the last day)
  • Get ISO 8601 week number for a given date
  • Get first and last day of month

PathUtils

Comprehensive static utility class for file path operations and manipulations:

  • Path normalization for consistent comparison
  • Drive letter normalization
  • UNC path handling
  • Path safety conversion for saving paths as filenames
  • Relative path calculation
  • Directory existence checks with auto-creation
  • Safe path combination logic

Usage Examples

DateTimeUtils

using AaTurpin.Utilities;
using System;

// Get the first day (Monday) of the current week
DateTime monday = DateTimeUtils.GetFirstDayOfWeek(DateTime.Today);

// Get the last day (Sunday) of the current week
DateTime sunday = DateTimeUtils.GetLastDayOfWeek(DateTime.Today);

// Get the ISO 8601 week number
int weekNumber = DateTimeUtils.GetIso8601WeekOfYear(DateTime.Today);

// Get the first day of the current month
DateTime firstDayOfMonth = DateTimeUtils.GetFirstDayOfMonth(DateTime.Today);

// Get the last day of the current month
DateTime lastDayOfMonth = DateTimeUtils.GetLastDayOfMonth(DateTime.Today);

PathUtils

using AaTurpin.Utilities;
using System;

// Normalize paths for consistent comparison
string normalizedPath = PathUtils.NormalizePath(@"C:\Users\Username\Documents\");
// Result: "c:\users\username\documents"

// Extract server name from UNC path
string serverName = PathUtils.ExtractServerFromUncPath(@"\\Server01\Share\Folder");
// Result: "Server01"

// Convert standard path to filesystem-safe format (for storage)
string safePath = PathUtils.ConvertToFileSystemSafePath(@"C:\Project Files\Document.docx");
// Result: "C\Project Files\Document.docx"

// Restore original path from filesystem-safe format
string originalPath = PathUtils.RestoreFromFileSystemSafePath(@"C\Project Files\Document.docx");
// Result: "C:\Project Files\Document.docx"

// Get relative path
string relativePath = PathUtils.GetRelativePath(@"C:\Projects\MyProject\src\file.cs", @"C:\Projects\MyProject");
// Result: "src\file.cs"

// Ensure directory exists (creates if needed)
bool dirExists = PathUtils.EnsureDirectoryExists(@"C:\Temp\NewFolder");

// Ensure directory exists for a file (creates parent directory if needed)
bool parentDirExists = PathUtils.EnsureDirectoryExistsForFile(@"C:\Temp\NewFolder\file.txt");

// Combine path segments safely
string combinedPath = PathUtils.CombinePath("C:", "Users", "Username", "Documents");
// Result: "C:\Users\Username\Documents"

Requirements

  • .NET Framework 4.7.2 or higher
  • Compatible with .NET Standard 2.0+ projects

License

MIT License

Keywords

utilities

FAQs

Package last updated on 30 Apr 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts