blob: f68118f2d6ca38cee042f7f02a63c619c71596e3 [file] [log] [blame]
// Copyright 2015 The Vanadium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
import { default as humanize } from 'npm:humanize'
export function formatDate(d) {
if(d === undefined || d == null) { return; }
var naturalDay = humanize.naturalDay(d.getTime() / 1000);
var naturalTime = humanize.date('g:i a', d);
return naturalDay + ' at ' + naturalTime;
}
export function formatRelativeTime(d) {
if(d === undefined || d == null) { return; }
return humanize.relativeTime(d.getTime() / 1000);
}
export function formatInteger(n) {
if(n === undefined || n == null) { return; }
return humanize.numberFormat(n, 0);
}
export function formatBytes(b) {
if(b === undefined || b == null) { return; }
return humanize.filesize(b);
}