Files
sdk/ux/duration.go
zeekayandHanzo Dev da299df77d the corporate name is Lux Industries Inc
Lux Partners Limited is not the entity behind this work. Every place the
old name stood — copyright lines, site footers, brand config, legal and
compliance text — now names the company that actually holds it.

lux.fund is the exception and is not renamed to match: that site belongs
to Lux Assets Management LLC, a different company, and it says so.

Two kinds of line were left for a person rather than rewritten. A dated
news item recording that Lux Partners Limited was established in the Isle
of Man is a historical fact, and renaming it would falsify the record. And
a sentence asserting that the company is domiciled in the Isle of Man is a
claim about a jurisdiction, not a name — an Inc or an LLC is not an Isle
of Man company, so swapping the name there would assert something untrue.

Co-authored-by: Hanzo Dev <[email protected]>
2026-08-28 13:05:15 -07:00

43 lines
890 B
Go

// Copyright (C) 2022, Lux Industries Inc All rights reserved.
// See the file LICENSE for licensing terms.
package ux
import (
"fmt"
"strings"
"time"
)
// FormatDuration returns a user friendly string for a duration
func FormatDuration(d time.Duration) string {
var sb strings.Builder
y := d / (24 * 365 * time.Hour)
if y > 0 {
d -= y * 24 * 365 * time.Hour
_, _ = sb.WriteString(fmt.Sprintf("%d years ", y))
}
dd := d / (24 * time.Hour)
if dd > 0 {
d -= dd * 24 * time.Hour
_, _ = sb.WriteString(fmt.Sprintf("%d days ", dd))
}
h := d / time.Hour
if h > 0 {
d -= h * time.Hour
_, _ = sb.WriteString(fmt.Sprintf("%d hours ", h))
}
m := d / time.Minute
if m > 0 {
d -= m * time.Minute
_, _ = sb.WriteString(fmt.Sprintf("%d minutes ", m))
}
s := d / time.Second
if s > 0 {
_, _ = sb.WriteString(fmt.Sprintf("%d seconds ", s))
}
return sb.String()
}