Persian.Plus
1.7.2
dotnet add package Persian.Plus --version 1.7.2
NuGet\Install-Package Persian.Plus -Version 1.7.2
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="Persian.Plus" Version="1.7.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Persian.Plus" Version="1.7.2" />
<PackageReference Include="Persian.Plus" />
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 Persian.Plus --version 1.7.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Persian.Plus, 1.7.2"
#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 Persian.Plus@1.7.2
#: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=Persian.Plus&version=1.7.2
#tool nuget:?package=Persian.Plus&version=1.7.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Persian.Plus
Utilities for Persian/Farsi text processing, validation, number conversion, and date handling in .NET.
Install
dotnet add package Persian.Plus
Features
- Persian text and phrase validation helpers
- Iranian national identifiers validation (National Code, National Legal Code, Postal Code)
- Iranian bank validations (IBAN, Shetab card)
- Iranian mobile number validation, coercion, and masking
- Persian/English number conversion and number-to-text (
Textify) - Persian calendar/date-time helpers (
PersianDateTime, events/holidays) - DataAnnotations attributes for model validation
- Persian text normalization utilities
PersianDateTime sample
using System;
using System.Linq;
using Persian.Plus.DateTime;
// 1) Create from Jalali date parts
var a = new PersianDateTime(1403, 12, 29, 14, 30, 45);
Console.WriteLine($"{a:yyyy/MM/dd HH:mm:ss}");
// Output: 1403/12/29 14:30:45
// 2) Convert from System.DateTime (Gregorian -> PersianDateTime)
var g = new DateTime(2025, 3, 20, 10, 0, 0);
var b = new PersianDateTime(g);
Console.WriteLine($"{b:yyyy/MM/dd HH:mm:ss}");
// Output: 1403/12/30 10:00:00
// 3) Parse supported string formats
var p1 = PersianDateTime.Parse("1404/01/01");
Console.WriteLine($"{p1:yyyy/MM/dd}");
// Output: 1404/01/01
var p1b = PersianDateTime.Parse("14040101");
Console.WriteLine($"{p1b:yyyy/MM/dd}");
// Output: 1404/01/01
var p2 = PersianDateTime.Parse("14040101112233");
Console.WriteLine($"{p2:yyyy/MM/dd HH:mm:ss}");
// Output: 1404/01/01 11:22:33
var unixSeconds = PersianDateTime.Parse("1711900800");
Console.WriteLine($"{unixSeconds:yyyy/MM/dd HH:mm:ss}");
// Output: (depends on local timezone conversion)
var unixMilliseconds = PersianDateTime.Parse("1711900800000");
Console.WriteLine($"{unixMilliseconds:yyyy/MM/dd HH:mm:ss}");
// Output: (depends on local timezone conversion)
// 4) TryParse
var ok = PersianDateTime.TryParse("1404-01-15", out var p3);
Console.WriteLine(ok);
// Output: True
Console.WriteLine($"{p3:yyyy/MM/dd}");
// Output: 1404/01/15
var bad = PersianDateTime.TryParse("not-a-date", out var _);
Console.WriteLine(bad);
// Output: False
// 5) Date arithmetic
var d = new PersianDateTime(1404, 1, 1);
Console.WriteLine($"{d.AddDays(10):yyyy/MM/dd}");
// Output: 1404/01/11
Console.WriteLine($"{d.AddMonths(1):yyyy/MM/dd}");
// Output: 1404/02/01
Console.WriteLine($"{d.AddYears(1):yyyy/MM/dd}");
// Output: 1405/01/01
// 6) Operators and comparisons
var x = new PersianDateTime(1404, 1, 1);
var y = new PersianDateTime(1404, 1, 2);
Console.WriteLine(x < y);
// Output: True
Console.WriteLine(y > x);
// Output: True
Console.WriteLine(x == new PersianDateTime(1404, 1, 1));
// Output: True
// 7) TimeSpan operators
var plus = x + TimeSpan.FromDays(5);
Console.WriteLine($"{plus:yyyy/MM/dd}");
// Output: 1404/01/06
var diff = y - x;
Console.WriteLine(diff.TotalDays);
// Output: 1
// 8) Implicit conversion with System.DateTime
DateTime systemDate = x;
PersianDateTime backToPersian = systemDate;
Console.WriteLine($"{backToPersian:yyyy/MM/dd}");
// Output: 1404/01/01
// 9) Properties
Console.WriteLine(x.Year); // Output: 1404
Console.WriteLine(x.Month); // Output: 1
Console.WriteLine(x.Day); // Output: 1
Console.WriteLine(x.IsLeapYear); // Output: False (for 1404)
Console.WriteLine(x.DaysInMonth); // Output: 31 (Farvardin)
// 10) Now
var now = PersianDateTime.Now;
Console.WriteLine($"{now:yyyy/MM/dd HH:mm:ss}");
// Output: (current Persian date/time)
// 11) Events and holidays in range
var start = new PersianDateTime(1404, 1, 1);
var end = new PersianDateTime(1404, 1, 31);
var events = start.GetEventsTill(end);
var holidays = events.Where(e => e.EventType.HasFlag(EventType.Holiday));
Console.WriteLine(holidays.Any());
// Output: True
Common extension samples
NormalizePersianText cleans and standardizes Persian text. Based on selected flags it can fix Arabic/Persian character variants (like ي → ی, ك → ک), apply half-space/ZWNJ rules, normalize spacing/line-breaks, remove diacritics, and run punctuation cleanup.
using Persian.Plus.Extensions;
using Persian.Plus.Extensions.Number;
using Persian.Plus.Extensions.Normalizer;
var validMobile = "09121234567".IsValidIranianMobileNumber();
// Output: true
var coerceMobile = "+989121234567".CoerceIranianMobileNumber();
// Output: 09121234567
var maskedMobile = "09121234567".MaskIranianMobileNumber();
// Output: 091212xxx67
var isPersianOnly = "علیرضا وفی".ContainsOnlyPersianLetters();
// Output: true
var isPersianOrEnglish = "علیرضا Vafi".ContainsOnlyPersianOrEnglishLetters();
// Output: true
var persianDigits = "123456".ToPersianNumbers();
// Output: ۱۲۳۴۵۶
var englishDigits = "۱۲۳۴۵۶".ToEnglishNumbers();
// Output: 123456
var words = 1250.Textify(Language.Persian);
// Output: یکهزار و دویست و پنجاه
var normalized = "سلام دنيا".NormalizePersianText(
PersianNormalizerFlags.ApplyPersianCharacters |
PersianNormalizerFlags.ApplyHalfSpaceRule |
PersianNormalizerFlags.CleanupSpacingAndLineBreaks);
// Output: سلام دنیا
DataAnnotations sample
using Persian.Plus.DataAnnotations;
public class PersonDto
{
[PersianLetters]
public string Name { get; set; }
[IranianNationalCode]
public string NationalCode { get; set; }
[IranianMobileNumber]
public string MobileNumber { get; set; }
}
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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 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 is compatible. 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.
-
net10.0
- No dependencies.
-
net8.0
- No dependencies.
-
net9.0
- No dependencies.
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Persian.Plus:
| Package | Downloads |
|---|---|
|
Persian.Plus.FluentValidation
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.7.2 | 98 | 5/21/2026 |
| 1.7.1 | 125 | 3/8/2026 |
| 1.7.0 | 1,701 | 10/30/2023 |
| 1.6.3 | 413 | 4/3/2023 |
| 1.6.1 | 2,029 | 10/17/2022 |
| 1.5.0 | 597 | 10/13/2022 |
| 1.4.2 | 889 | 10/10/2022 |
| 1.4.1 | 510 | 10/10/2022 |
| 1.4.0 | 1,218 | 8/14/2022 |
| 1.3.0 | 690 | 4/21/2022 |
| 1.2.0 | 605 | 4/21/2022 |
| 1.1.0 | 804 | 4/18/2022 |
| 1.0.7 | 606 | 4/13/2022 |
| 1.0.6 | 622 | 1/16/2022 |
| 1.0.5 | 502 | 12/17/2021 |
| 1.0.4 | 780 | 7/20/2021 |
| 1.0.3 | 983 | 4/16/2021 |
| 1.0.2 | 485 | 4/15/2021 |
| 1.0.1 | 495 | 4/14/2021 |