Portage complet PHP/Bash vers Node.js (Fastify + worker_threads)
This commit is contained in:
21
lib/format.js
Normal file
21
lib/format.js
Normal file
@@ -0,0 +1,21 @@
|
||||
// Money formatting (Intl.NumberFormat replaces PHP's NumberFormatter::CURRENCY).
|
||||
|
||||
const FMT = new Intl.NumberFormat('en-US', {
|
||||
style: 'currency',
|
||||
currency: 'USD',
|
||||
maximumFractionDigits: 0,
|
||||
minimumFractionDigits: 0,
|
||||
});
|
||||
|
||||
export function formatCurrency(n) {
|
||||
return FMT.format(n || 0);
|
||||
}
|
||||
|
||||
export function pad2(n) {
|
||||
return n < 10 ? `0${n}` : String(n);
|
||||
}
|
||||
|
||||
export function formatRuntime(runtime) {
|
||||
if (!runtime) return '';
|
||||
return `${Math.floor(runtime / 60)} h ${pad2(runtime % 60)} min`;
|
||||
}
|
||||
Reference in New Issue
Block a user