Files
threshold/internal/db/timestamp/timestamp.go
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

29 lines
577 B
Go
Raw Normal View History

2023-02-02 17:15:17 -08:00
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: BUSL-1.1
2021-06-11 11:36:14 -07:00
package timestamp
import (
"time"
"google.golang.org/protobuf/types/known/timestamppb"
)
// New constructs a new Timestamp from the provided time.Time.
func New(t time.Time) *Timestamp {
return &Timestamp{
Timestamp: timestamppb.New(t),
}
}
// Now constructs a new Timestamp from the current time.
func Now() *Timestamp {
return &Timestamp{
Timestamp: timestamppb.Now(),
}
}
// AsTime converts x to a time.Time.
2024-02-13 10:54:48 -05:00
func (ts *Timestamp) AsTime() time.Time {
return ts.GetTimestamp().AsTime()
2021-06-11 11:36:14 -07:00
}