This repository has been archived by the owner on Jun 3, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
/
numberToWordsExtension.ts
41 lines (37 loc) · 1.71 KB
/
numberToWordsExtension.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
interface Number
{
toWords(culture?: string): string;
toWords(gender: Humanizer.GrammaticalGender, culture?: string): string;
toOrdinalWords(culuture?: string): string;
toOrdinalWords(gender: Humanizer.GrammaticalGender, culture?: string): string;
}
module Humanizer
{
"use strict";
/**
* 3501.ToWords() -> "three thousand five hundred and one"
*/
Number.prototype.toWords = function (): string
{
/// <summary>
/// 3501.ToWords() -> "three thousand five hundred and one"
/// </summary>
var gender: GrammaticalGender = arguments.length >= 1 && typeof arguments[0] === "number" ? arguments[0] : null;
var converter: Humanizer.Localisation.NumberToWords.INumberToWordsConverter = Configuration.Configurator.getNumberToWordsConverter(arguments.length > 0 && typeof arguments[arguments.length - 1] === "string" ? arguments[arguments.length - 1] : Resources.getCurrentCulture());
if (gender === null)
{
return converter.convert(this);
}
return converter.convert(this, gender);
};
Number.prototype.toOrdinalWords = function (): string
{
var gender: GrammaticalGender = arguments.length >= 1 && typeof arguments[0] === "number" ? arguments[0] : null;
var converter: Humanizer.Localisation.NumberToWords.INumberToWordsConverter = Configuration.Configurator.getNumberToWordsConverter(arguments.length > 0 && typeof arguments[arguments.length - 1] === "string" ? arguments[arguments.length - 1] : Resources.getCurrentCulture());
if (gender === null)
{
return converter.convertToOrdinal(this);
}
return converter.convertToOrdinal(this, gender);
};
}