Skip to content
Discussion options

You must be logged in to vote

Hello!

Currently, Humanizer focuses on humanizing types (integers, dates, enums) rather than specific financial currency patterns. To achieve the 'Rupees and Paise' format, the best approach is to humanize the integer and fractional parts separately.

You can achieve this with the following approach (or similar):

using Humanizer;

public string HumanizeCurrency(decimal amount)
{
    // 1. Get the main units (Rupees)
    int rupees = (int)Math.Truncate(amount);
    
    // 2. Get the subunits (Paise), rounding it to 2 decimal places
    int paise = (int)((amount - rupees) * 100);

    // 3. Humanize both parts
    string rupeesPart = rupees.ToWords();
    string paisePart = paise.ToWords();

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by fingers10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants