Gufel.Date 1.0.0

dotnet add package Gufel.Date --version 1.0.0
                    
NuGet\Install-Package Gufel.Date -Version 1.0.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="Gufel.Date" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Gufel.Date" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Gufel.Date" />
                    
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 Gufel.Date --version 1.0.0
                    
#r "nuget: Gufel.Date, 1.0.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 Gufel.Date@1.0.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=Gufel.Date&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Gufel.Date&version=1.0.0
                    
Install as a Cake Tool

Gufel.Date

Gufel.Date is a flexible and powerful date manipulation library for .NET that provides support for multiple calendar systems, including Persian (Jalali) and Hijri calendars.

Features

  • Multi-calendar support (Persian/Jalali, Hijri, Gregorian)
  • Easy conversion between different calendar systems
  • Date formatting with custom patterns
  • Date comparison and calculations
  • Age calculation
  • Date span calculations
  • Implicit and explicit type conversions
  • String parsing

Installation

Install the package via NuGet:

dotnet add package Gufel.Date

Usage

Basic Usage

// Create a VDate from current date and time (default is Persian calendar)
var now = VDate.Now;

// Create a VDate from a specific date
var date = new VDate(1404, 3, 11); // Persian date (year, month, day)

// Convert to DateTime
DateTime dateTime = date.ToDateTime();

// Convert from DateTime to VDate
var vDate = new VDate(DateTime.Now);

Working with Different Calendars

// Create a date with Hijri calendar
var hijriDate = new VDate(VDateSettingFactory.GetSetting("ar"), DateTime.Now);

// Get year, month, day
Console.WriteLine($"Hijri Year: {hijriDate.Year}");
Console.WriteLine($"Hijri Month: {hijriDate.Month}");
Console.WriteLine($"Hijri Day: {hijriDate.Day}");

Date Formatting

var date = new VDate(1404, 3, 11, 14, 10, 23);

// Format as string
string formatted = date.ToString("f"); // Full date/time pattern
// Output: "یکشنبه, 11 خرداد 1404 14:10:23 ب.ظ"

// Custom format
string custom = date.ToString("$yyyy/$MM/$dd");
// Output: "1404/03/11"

Date Comparison

var date1 = new VDate(1404, 3, 11);
var date2 = new VDate(1404, 3, 12);

bool isEqual = date1 == date2; // false
bool isLess = date1 < date2;   // true
bool isGreater = date1 > date2; // false

Date Parsing

// Parse from string
if (VDate.TryParse("1404/03/11", out var parsedDate))
{
    Console.WriteLine($"Year: {parsedDate.Year}, Month: {parsedDate.Month}, Day: {parsedDate.Day}");
}

Type Conversions

// Convert from integer (YYYYMMDD format)
int dateInt = 14040311;
VDate dateFromInt = dateInt;

// Convert to integer
int intValue = dateFromInt; // 14040311

// Convert to string
string dateString = (string)dateFromInt; // "1404/03/11"

// Convert from string
VDate dateFromString = (VDate)"1404/03/11";

Format Patterns

The ToString(string format) method supports the following patterns:

  • $dddd - Day name (e.g., "یکشنبه")
  • $dd - Day of month with leading zero (e.g., "01")
  • $d - Day of month (e.g., "1")
  • $MMMM - Month name (e.g., "خرداد")
  • $MM - Month with leading zero (e.g., "03")
  • $M - Month (e.g., "3")
  • $yyyy - 4-digit year (e.g., "1404")
  • $yy - 2-digit year (e.g., "04")
  • $HH - Hour with leading zero, 24-hour format (e.g., "14")
  • $H - Hour, 24-hour format (e.g., "14")
  • $hh - Hour with leading zero, 12-hour format (e.g., "02")
  • $h - Hour, 12-hour format (e.g., "2")
  • $mm - Minute with leading zero (e.g., "05")
  • $m - Minute (e.g., "5")
  • $ss - Second with leading zero (e.g., "09")
  • $s - Second (e.g., "9")
  • $g - AM/PM designator (e.g., "ب.ظ" for PM in Persian)

Predefined formats:

  • f or F - Full date/time pattern
  • s or S - Sortable date/time pattern
Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  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.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Gufel.Date:

Package Downloads
Gufel.ExcelBuilder

This project provides a flexible and extensible framework for building and exporting Excel files in .NET

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0 291 6/10/2025