debug: poor man's pretty @da fractional seconds

Lossy, but if the original ms timestamp came out of an urbit, it was
already lossy anyway.
This commit is contained in:
fang 2024-04-08 15:56:50 +02:00
parent 69e357b161
commit 3ecae833ab
No known key found for this signature in database
GPG Key ID: EB035760C1BBA972

View File

@ -13,7 +13,7 @@ export function makeRoutePath(resource, includeQuery = false) {
export function msToDa(ms, mil) {
const d = new Date(ms);
var fil = function(n) {
const fil = function(n) {
return n >= 10 ? n : "0" + n;
};
return (
@ -23,7 +23,10 @@ export function msToDa(ms, mil) {
`${fil(d.getUTCHours())}.` +
`${fil(d.getUTCMinutes())}.` +
`${fil(d.getUTCSeconds())}` +
`${mil ? "..0000" : ""}`
//NOTE poor man's pretty @da milliseconds
`${!mil ? '' :
'..' + Math.floor((d.getUTCMilliseconds() / 1000) * 0x10000)
.toString(16).padStart(4, '0')}`
);
}