Debian Codegraph @

time.go

raw symbols SCIP
1 package mlog
2
3 import (
4 "time"
5
6 "github.com/cactus/tai64"
7 )
8
9 func writeTime(sb intSliceWriter, t *time.Time, flags FlagSet) {
10 year, month, day := t.Date()
11 sb.AppendIntWidth(year, 4)
12 sb.WriteByte('-')
13 sb.AppendIntWidth(int(month), 2)
14 sb.WriteByte('-')
15 sb.AppendIntWidth(day, 2)
16
17 sb.WriteByte('T')
18
19 hour, min, sec := t.Clock()
20 sb.AppendIntWidth(hour, 2)
21 sb.WriteByte(':')
22 sb.AppendIntWidth(min, 2)
23 sb.WriteByte(':')
24 sb.AppendIntWidth(sec, 2)
25
26 sb.WriteByte('.')
27 sb.AppendIntWidth(t.Nanosecond(), 9)
28
29 _, offset := t.Zone()
30 if offset == 0 {
31 sb.WriteByte('Z')
32 } else {
33 if offset < 0 {
34 sb.WriteByte('-')
35 offset = -offset
36 } else {
37 sb.WriteByte('+')
38 }
39 sb.AppendIntWidth(offset/3600, 2)
40 sb.WriteByte(':')
41 sb.AppendIntWidth(offset%3600, 2)
42 }
43 }
44
45 func writeTimeTAI64N(sb intSliceWriter, t *time.Time, flags FlagSet) {
46 tu := t.UTC()
47 tux := tu.Unix()
48 offset := tai64.GetOffsetUnix(tux)
49 sb.WriteString("@4")
50 sb.AppendIntWidthHex(tux+offset, 15)
51 sb.AppendIntWidthHex(int64(tu.Nanosecond()), 8)
52 }