blob: dc2e6c5809b1d32cd0cc53b5759c68f9bfc7ba86 (
plain)
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
|
package cobol
// time is relative. keep it that way.
import (
"fmt"
"time"
)
// there is only one way to display the time as text
// this is that way. Don't like it? Don't use COBOL
func FormatTime(t time.Time) string {
s := t.UTC().Format("2006/01/02 15:04:03")
dur := time.Since(t)
//always time, two spaces, (duration)
return fmt.Sprintf("%s (%-5.5s)", s, FormatDuration(dur))
}
func FormatTimeLocal(t time.Time) string {
localTime := t.Local()
s := localTime.Format("2006/01/02 15:04:03")
now := time.Now()
if now.Before(t) {
return s + " (future)"
}
dur := time.Since(t)
//always time, two spaces, (duration)
return s + " (" + FormatDuration(dur) + ")"
}
|