-
Notifications
You must be signed in to change notification settings - Fork 6
/
time.go
32 lines (26 loc) · 1.01 KB
/
time.go
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
// Copyright 2022 The incite Authors. All rights reserved.
// Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file.
package incite
import "time"
// TimeLayout is a Go time layout which documents the format of the time
// values returned within the timestamp fields of CloudWatch Logs
// Insights queries.
//
// TimeLayout defines the format by showing how the Go reference time of
//
// Mon Jan 2 15:04:05 -0700 MST 2006
//
// would be formatted if it were the value. TimeLayout can be used with
// time.Parse to parse timestamp fields, such as @timestamp and @ingestionTime,
// which are returned within CloudWatch Logs Insights query results.
const TimeLayout = "2006-01-02 15:04:05.000"
func hasSubMillisecond(t time.Time) bool {
return t.Nanosecond()%int(time.Millisecond) != 0
}
func hasSubMillisecondD(d time.Duration) bool {
return d%time.Millisecond > 0
}
func epochMillisecond(t time.Time) int64 {
return t.Unix()*1000 + int64(t.Nanosecond())/int64(time.Millisecond)
}