Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemathinc
GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/packages/util/licenses/purchase/utils.ts
1450 views
1
/*
2
* This file is part of CoCalc: Copyright © 2020 Sagemath, Inc.
3
* License: MS-RSL – see LICENSE.md for details
4
*/
5
6
export function money(n: number, hideCurrency: boolean = false): string {
7
let s;
8
if (n == 0) {
9
s = "0";
10
} else {
11
s = new Intl.NumberFormat(undefined, {
12
style: "currency",
13
currency: "USD",
14
minimumFractionDigits: 0,
15
}).format(n);
16
const i = s.indexOf(".");
17
if (i == -1) {
18
s += ".00";
19
} else if (i == s.length - 2) {
20
s += "0";
21
}
22
}
23
return (hideCurrency ? "" : "USD ") + s;
24
}
25
26