aboutsummaryrefslogtreecommitdiffstats
path: root/common/format.go
blob: 119637d2e4fecbef0de8cd7b6bb5c8910cbe2019 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// Copyright 2016 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
// The go-ethereum library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// The go-ethereum library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.

package common

import (
    "fmt"
    "regexp"
    "strings"
    "time"
)

// PrettyDuration is a pretty printed version of a time.Duration value that cuts
// the unnecessary precision off from the formatted textual representation.
type PrettyDuration time.Duration

var prettyDurationRe = regexp.MustCompile("\\.[0-9]+")

// String implements the Stringer interface, allowing pretty printing of duration
// values rounded to three decimals.
func (d PrettyDuration) String() string {
    label := fmt.Sprintf("%v", time.Duration(d))
    if match := prettyDurationRe.FindString(label); len(match) > 4 {
        label = strings.Replace(label, match, match[:4], 1)
    }
    return label
}
td>-2/+2 * change the libtool version to use from 1.3 to 1.5oliver2005-06-032-21/+1 * - Rework gpgme03 port to avoid conflict with gpgme 1.0clement2004-12-211-3/+4 * Switch gpgme dependency to gpgme03.marcus2004-12-111-1/+1 * Increase USE_GCC to 3.4 for those ports which compile with it.kris2004-09-301-1/+1 * Chase the libpspell shared lib version.marcus2004-08-301-1/+2 * Update to version 0.4.6-17krion2004-08-039-1141/+12 * - Add the X_WINDOW_SYSTEM={xorg,xfree86-4,xfree86-3} variable to bsd.port.mk,anholt2004-07-241-1/+1 * Sync with new bsd.autotools.mkade2004-06-051-1/+1 * Chase the new location of libXft.marcus2004-03-171-1/+1 * Whoa there, boy, that's a mighty big commit y'all have there...ade2004-03-141-1/+1 * Fix build on non-i386 arch.linimon2004-02-137-4/+1112 * Bump PORTREVISION on all ports that depend on gettext to aid with upgrading.marcus2004-02-041-0/+1 * - Update to version 0.4.6krion2004-02-015-58/+61 * - Move everybuddy to ayttm, and update to version 0.4.5krion2004-01-096-96/+152 * Jim Mock (jim) returned his commit bit, so set his ports free.pav2003-12-151-1/+1 * Allow everybuddy to find its module files at startup (correct REINPLACEkris2003-10-121-2/+2 * libtool uber-patchade2003-06-271-1/+3 * Remove USE_GNOMENG.marcus2003-04-211-1/+0 * Clear moonlight beckons.ade2003-03-072-1/+1 * Deploy USE_GNOMENG infrastructurelioux2002-09-031-4/+6 * Update to 0.4.3.jim2002-08-134-6/+25 * Make an attempt at fixing the modules so they're actually usable.jim2002-07-042-2/+19