BstHelpers 10.0.14

BstHelpers

Helper library with formatting, string utilities, and humanization for .NET projects (PT-PT defaults).

Settings

Override the static defaults on BstHelperSettings once at startup:

BstHelperSettings.DateFormat = "dd/MM/yyyy";
BstHelperSettings.CurrencySign = "€";
BstHelperSettings.PercentageSign = "%";
BstHelperSettings.DecimalSeparator = ",";
BstHelperSettings.ThousandsSeparator = " ";
BstHelperSettings.TimeSeparator = ":";
BstHelperSettings.DecimalPlaces = 2;
BstHelperSettings.CurrencySignBefore = false;
BstHelperSettings.PercentageSignBefore = false;
BstHelperSettings.LocalTimeZone = TimeZoneInfo.FindSystemTimeZoneById("Europe/Lisbon");

LocalTimeZone controls the timezone used when rendering DateTimeOffset values via FormatDate() / FormatTime(). Defaults to Europe/Lisbon (falls back to GMT Standard Time, then UTC, if the timezone is not available on the host).

Usage

Date & time formatting

DateTime date = DateTime.Now;
date.FormatDate();                          // "03-05-2026"
date.FormatDate(minutes: true);             // "03-05-2026 14:30"
date.FormatDate(seconds: true);             // "03-05-2026 14:30:45"
date.FormatTime();                          // "14:30"

DateTimeOffset utc = DateTimeOffset.UtcNow;
utc.FormatDate(minutes: true);              // rendered in BstHelperSettings.LocalTimeZone
utc.FormatTime();                           // rendered in BstHelperSettings.LocalTimeZone

DateTime? maybe = null;
maybe.FormatDate(replaceNull: "—");         // "—"

// Convert a naive DateTime to DateTimeOffset
var dto = DateTime.Now.ConvertToDateTimeOffset(DateTimeKind.Local);

Number formatting

1234.5m.FormatNumber();                                  // "1 234,50"
1234.5m.FormatNumber(currencySign: true);                // "1 234,50€"
0.25m.FormatNumber(percentageSign: true, decimalPlaces: 0); // "0%"
1234.5m.FormatNumber(autoDecimalPlaces: true);           // "1 234,5"
1234.5m.FormatNumber(javascript: true);                  // "1234.50"  (locale-neutral)
0m.FormatNumber(replaceZero: "—");                       // "—"

12.3456m.Round(2);                                       // 12.35

String helpers

"Some long text".Truncate(8, "…");           // "Some lon…"
"<p>Hello <b>world</b></p>".StripHtml();     // "Hello world"
"hello world".ToTitleCase();                 // "Hello World"
"  ".ReplaceEmpty("(empty)");                // "(empty)"

"123456789".IsValidPortugueseVat();
"1000-001".IsValidPortuguesePostalCode();
"foo@bar.com".IsValidEmail();
"foo@bar.com".NormalizeEmail();
"912345678".IsValidPhoneNumber();
"912345678".FormatPhoneNumber();             // "912 345 678"
"912345678".HidePhoneNumber();               // "XXX XXX X78"
"123456789".FormatMultibancoReference();     // "123 456 789"
"12345".FormatMultibancoEntity();            // "12 345"

"file/name?.txt".RemoveInvalidPathChars();
"https://youtu.be/abc123".YouTubeUrlToEmbed();
"foo@bar.com".GetEmailLink();                // "<a href=\"mailto:...\">...</a>"

Slugs

SlugHelper.GenerateSlug("Olá Mundo!");       // "ola-mundo"
SlugHelper.GenerateSlug("Olá Mundo", 2);     // "ola-mundo-2"

Humanization (PT-PT)

Humanizer.GetMonthName(DateTime.Now);        // "Maio"
Humanizer.GetMonthName(7);                   // "Julho"
Humanizer.GetWeekDay(DateTime.Now);          // "domingo"
Humanizer.GetGreeting();                     // "Bom dia" / "Boa tarde" / "Boa noite"
Humanizer.CurrencyWriting(125.50m);          // "cento e vinte e cinco euros e cinquenta cêntimos"

Pass a CultureInfo to override the default pt-PT culture on month/weekday helpers.

Showing the top 20 packages that depend on BstHelpers.

Packages Downloads
BstBulk
Biblioteca para operações bulk no SQL Server
14
BstBulk
Biblioteca para operações bulk no SQL Server
16
BstBulk
Biblioteca para operações bulk no SQL Server
18
BstLogger
Logging helper
15
BstLogger
Logging helper
16
BstLogger
Logging helper
19
BstTranslations
Translations support
14
BstTranslations
Translations support
15
BstTranslations
Translations support
17
BstTranslations
Translations support
20
BstTranslations
Translations support
21
BstTranslations
Translations support
24
BstTranslations
Translations support
28
BstTranslations
Translations support
46

Version Downloads Last updated
10.0.14 3 03/05/2026
10.0.13 9 23/04/2026
10.0.12 8 16/04/2026
10.0.10 29 20/03/2026
10.0.9 4 20/03/2026
10.0.8 4 20/03/2026
10.0.7 5 20/03/2026
10.0.6 18 11/03/2026
10.0.5 16 10/02/2026
10.0.4 8 28/01/2026
10.0.3 7 28/01/2026
10.0.2 26 12/12/2025
10.0.1 17 11/11/2025
9.2.6 17 06/11/2025
9.2.5 10 31/10/2025
9.2.4 8 20/10/2025
9.2.3 7 20/10/2025
9.2.2 9 15/10/2025
9.2.1 10 24/09/2025
9.2.0 18 06/09/2025
9.1.9 20 26/07/2025
9.1.8 12 15/07/2025
9.1.7 17 12/06/2025
9.1.6 45 19/05/2025
9.1.5 14 14/05/2025
9.1.4 30 09/04/2025
9.1.3 36 22/03/2025
9.1.2 14 19/03/2025
9.1.1 20 05/03/2025
9.1.0 14 01/03/2025
9.0.9 33 12/02/2025
9.0.8 31 28/01/2025
9.0.7 18 23/01/2025
9.0.6 20 12/01/2025
9.0.5 18 15/12/2024
9.0.4 16 13/12/2024
9.0.3 17 03/12/2024
9.0.2 25 27/11/2024
9.0.1 37 13/11/2024
8.0.4 17 12/11/2024
8.0.3 20 07/11/2024
8.0.2 15 04/11/2024
8.0.1 21 30/10/2024
2.3.6 16 16/10/2024
2.3.5 14 10/10/2024
2.3.4 13 08/10/2024
2.3.3 15 03/10/2024
2.3.2 24 21/08/2024
2.3.1 15 21/08/2024
2.3.0 15 21/08/2024
2.2.8 16 20/08/2024
2.2.7 15 19/08/2024
2.2.6 16 16/08/2024
2.2.5 15 16/08/2024
2.2.4 32 14/06/2024
2.2.3 28 18/05/2024
2.2.2 23 08/05/2024
2.2.1 23 17/04/2024
2.2.0 21 15/04/2024
2.1.6 21 09/04/2024
2.1.5 24 09/04/2024
2.1.0 14 06/03/2024
2.0.8 22 06/03/2024
2.0.5 22 16/08/2024
2.0.2 26 01/09/2023
2.0.1 25 28/08/2023
1.0.1 16 28/08/2023